72 int shift_h[4] = { 0 }, shift_v[4] = { 0 };
81 memset(
c, 0,
sizeof(*
c));
84 shift_h[2] = shift_h[1];
85 shift_v[2] = shift_v[1];
88 for (
int p = 0;
frame->data[p]; p++) {
91 uint32_t checksum = 0;
95 for (
int j = 0; j <
frame->height >> shift_v[p]; j++) {
100 c->checksum[p] = checksum;
113 fprintf(stderr,
"Error retrieving a reconstructed frame\n");
130 fprintf(stderr,
"Error converting pixel formats\n");
152 fprintf(stderr,
"No input frames were decoded\n");
168 fprintf(stderr,
"Error opening the encoder\n");
184 fprintf(stderr,
"Error submitting a frame for encoding\n");
197 fprintf(stderr,
"Error receiving a frame from the encoder\n");
209 fprintf(stderr,
"No packets were received from the encoder\n");
227 fprintf(stderr,
"Error opening the decoder\n");
234 fprintf(stderr,
"Error sending a packet to decoder\n");
245 fprintf(stderr,
"Error receiving a frame from decoder\n");
265 if (ca->
ts ==
cb->ts)
275 const char *filename, *
enc_name, *enc_opts, *thread_type =
NULL, *nb_threads =
NULL;
277 int ret = 0, max_frames = 0;
281 "Usage: %s <input file> <encoder> <encoder options> "
282 "[<max frame count> [<thread count> <thread type>]\n",
291 max_frames = strtol(argv[4],
NULL, 0);
293 nb_threads = argv[5];
295 thread_type = argv[6];
297 memset(&dc, 0,
sizeof(dc));
298 memset(&pd, 0,
sizeof(pd));
302 fprintf(stderr,
"No such encoder: %s\n",
enc_name);
306 fprintf(stderr,
"Encoder '%s' cannot output reconstructed frames\n",
319 fprintf(stderr,
"Error allocating encoder\n");
325 fprintf(stderr,
"Error setting encoder options\n");
332 fprintf(stderr,
"Error allocating decoder\n");
347 ret =
ds_open(&dc, filename, 0);
349 fprintf(stderr,
"Error opening the file\n");
365 fprintf(stderr,
"Mismatching frame counts: recon=%zu decoded=%zu\n",
381 fprintf(stderr,
"Checksum mismatch in frame ts=%"PRId64
", plane %d\n",
Public header for Adler-32 hash function implementation.
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Libavcodec external API header.
#define i(width, name, range_min, range_max)
common internal and external API header
int ds_open(DecodeContext *dc, const char *url, int stream_idx)
void ds_free(DecodeContext *dc)
int ds_run(DecodeContext *dc)
#define AV_EF_CRCCHECK
Verify checksums embedded in the bitstream (could be of either encoded or decoded data,...
static int process_frame(DecodeContext *dc, AVFrame *frame)
static int recon_frame_process(PrivData *pd, const AVPacket *pkt)
static int frame_hash(FrameChecksum **pc, size_t *nb_c, int64_t ts, const AVFrame *frame)
static int frame_checksum_compare(const void *a, const void *b)
static av_always_inline int process_frame(AVTextFormatContext *tfc, InputFile *ifile, AVFrame *frame, const AVPacket *pkt, int *packet_new)
reference-counted frame API
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
const AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
const AVCodec * avcodec_find_encoder_by_name(const char *name)
Find a registered encoder with the specified name.
#define AV_CODEC_CAP_ENCODER_RECON_FRAME
The encoder is able to output reconstructed frame data, i.e.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
#define AV_CODEC_FLAG_RECON_FRAME
Request the encoder to output reconstructed frames, i.e. frames that would be produced by decoding th...
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Alias for avcodec_receive_frame_flags(avctx, frame, 0).
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
int avcodec_is_open(AVCodecContext *s)
void av_packet_free(AVPacket **pkt)
Free the packet, if the packet is reference counted, it will be unreferenced first.
AVPacket * av_packet_alloc(void)
Allocate an AVPacket and set its fields to default values.
AVAdler av_adler32_update(AVAdler adler, const uint8_t *buf, size_t len)
Calculate the Adler32 checksum of a buffer.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
#define AVERROR_EOF
End of file.
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
void * av_memdup(const void *p, size_t size)
Duplicate a buffer with av_malloc().
int av_image_get_linesize(enum AVPixelFormat pix_fmt, int width, int plane)
Compute the size of an image line with format pix_fmt and width width for the plane plane.
@ AV_PICTURE_TYPE_NONE
Undefined.
int sws_scale_frame(SwsContext *sws, AVFrame *dst, const AVFrame *src)
Scale source data from src and write the output to dst.
SwsContext * sws_getContext(int srcW, int srcH, enum AVPixelFormat srcFormat, int dstW, int dstH, enum AVPixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)
Allocate and return an SwsContext.
int av_set_options_string(void *ctx, const char *opts, const char *key_val_sep, const char *pairs_sep)
Parse the key/value pairs list in opts.
Memory handling functions.
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
#define FF_ARRAY_ELEMS(a)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int width
picture width / height.
int thread_type
Which multithreading methods to use.
int thread_count
thread count is used to decide how many independent tasks should be passed to execute()
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented.
int flags
AV_CODEC_FLAG_*.
uint8_t * extradata
Out-of-band global headers that may be used by some codecs.
int err_recognition
Error recognition; may misdetect some more or less valid parts as errors.
const char * name
Name of the codec implementation.
int capabilities
Codec capabilities.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
This structure stores compressed data.
Rational number (pair of numerator and denominator).
AVDictionary * decoder_opts
int(* process_frame)(struct DecodeContext *dc, AVFrame *frame)
size_t nb_checksums_decoded
size_t nb_checksums_recon
FrameChecksum * checksums_decoded
FrameChecksum * checksums_recon
struct SwsContext * scaler
Main external API structure.
static double cb(void *priv, double x, double y)