赞
踩
#include "libavutil/adler32.h" #include "libavcodec/avcodec.h" #include "libavformat/avformat.h" #include "libavutil/imgutils.h" int64_t *pts_array; uint32_t *crc_array; int size_of_array; int number_of_elements; static int add_crc_to_array(uint32_t crc, int64_t pts) { if (size_of_array <= number_of_elements) { if (size_of_array == 0) size_of_array = 10; size_of_array *= 2; crc_array = av_realloc_f(crc_array, size_of_array, sizeof(uint32_t)); pts_array = av_realloc_f(pts_array, size_of_array, sizeof(int64_t)); if ((crc_array == NULL) || (pts_array == NULL)) { av_log(NULL, AV_LOG_ERROR, "Can't allocate array to store crcs\n"); return AVERROR(ENOMEM); } } crc_array[number_of_elements] = crc; pts_array[number_of_elements] = pts; number_of_elements++; return 0; } static int compare_crc_in_array(uint32_t crc, int64_t pts) { int i; for (i = 0; i < number_of_elements; i++) { if (pts_array[i] == pts) { if (crc_array[i] == crc) { printf("Comparing 0x%08"PRIx32" %"PRId64" %d is OK\n", crc, pts, i); return 0; } else { av_log(NULL, AV_LOG_ERROR, "Incorrect crc of a frame after seeking\n"); return -1; } } } av_log(NULL, AV_LOG_ERROR, "Incorrect pts of a frame after seeking\n"); return -1; } static int compute_crc_of_packets(AVFormatContext *fmt_ctx, int video_stream, AVCodecContext *ctx, AVPacket *pkt, AVFrame *fr, uint64_t ts_start, uint64_t ts_end, int no_seeking) { int number_of_written_bytes; int result; int byte_buffer_size; uint8_t *byte_buffer; uint32_t crc; byte_buffer_size =
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。