37 #include <sys/types.h>
51 static uint64_t frame_cnt = 0;
56 fprintf(stderr,
"Error sending a packet for decoding: %s\n",
av_err2str(ret));
69 fprintf(stderr,
"Error during decoding: %s\n",
av_err2str(ret));
75 "#format: frame checksums\n"
79 "#media_type 0: video\n"
80 "#codec_id 0: rawvideo\n"
81 "#dimensions 0: 352x288\n"
83 "#stream#, dts, pts, duration, size, hash\n");
100 printf(
"0, %10"PRId64
", %10"PRId64
", 1, %8d, %s\n",
101 frame_cnt, frame_cnt,
109 int main(
int argc,
char **argv)
114 unsigned int threads;
118 int nals = 0, ret = 0;
122 fprintf(stderr,
"Usage: %s <threads> <input file>\n", argv[0]);
126 if (!(threads = strtoul(argv[1],
NULL, 0)))
132 setmode(fileno(stdout), O_BINARY);
145 fprintf(stderr,
"Codec not found\n");
151 fprintf(stderr,
"Could not allocate video codec context\n");
161 c->thread_count = threads;
164 fprintf(stderr,
"Could not open codec\n");
170 fprintf(stderr,
"Couldn't activate slice threading: %d\n",
c->active_thread_type);
175 fprintf(stderr,
"WARN: not using threads, only checking decoding slice NALUs\n");
179 fprintf(stderr,
"Could not allocate video frame\n");
184 if (!(file = fopen(argv[2],
"rb"))) {
185 fprintf(stderr,
"Couldn't open NALU file: %s\n", argv[2]);
192 size_t ret = fread(&
size, 1,
sizeof(uint16_t), file);
193 if (ret !=
sizeof(uint16_t))
197 ret = fread(p, 1,
size, file);
199 perror(
"Couldn't read data");
204 if (++nals >= threads) {
int main(int argc, char **argv)
static int decode(AVCodecContext *dec_ctx, AVFrame *frame, AVPacket *pkt)
Libavcodec external API header.
#define FF_THREAD_SLICE
Decode more than one part of a single frame at once.
static AVCodecContext * dec_ctx
int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
AVCodec * avcodec_find_decoder(enum AVCodecID id)
Find a registered decoder with a matching codec ID.
#define AV_CODEC_FLAG2_CHUNKS
Input bitstream might be truncated at a packet boundaries instead of only at frame boundaries.
AVCodecContext * avcodec_alloc_context3(const AVCodec *codec)
Allocate an AVCodecContext and set its fields to default values.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
#define AV_INPUT_BUFFER_PADDING_SIZE
Required number of additionally allocated bytes at the end of the input bitstream for decoding.
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.
#define AVERROR_EOF
End of file.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
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_hash_freep(AVHashContext **ctx)
Free hash context and set hash context pointer to NULL.
void av_hash_final_hex(struct AVHashContext *ctx, uint8_t *dst, int size)
Finalize a hash context and store the hexadecimal representation of the actual hash value as a string...
void av_hash_init(AVHashContext *ctx)
Initialize or reset a hash context.
void av_hash_update(AVHashContext *ctx, const uint8_t *src, int len)
Update a hash context with additional data.
int av_hash_alloc(AVHashContext **ctx, const char *name)
Allocate a hash context for the algorithm specified by name.
#define AV_HASH_MAX_SIZE
Maximum value that av_hash_get_size() will currently return.
int av_hash_get_size(const AVHashContext *ctx)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
main external API structure.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
This structure describes decoded (raw) audio or video data.
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
This structure stores compressed data.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...