diff options
Diffstat (limited to 'modules/avcodec/decode.c')
-rw-r--r-- | modules/avcodec/decode.c | 42 |
1 files changed, 29 insertions, 13 deletions
diff --git a/modules/avcodec/decode.c b/modules/avcodec/decode.c index 77e6e77..759535c 100644 --- a/modules/avcodec/decode.c +++ b/modules/avcodec/decode.c @@ -16,13 +16,6 @@ #include "avcodec.h" -#if LIBAVUTIL_VERSION_MAJOR < 52 -#define AV_PIX_FMT_YUV420P PIX_FMT_YUV420P -#define AV_PIX_FMT_YUVJ420P PIX_FMT_YUVJ420P -#define AV_PIX_FMT_NV12 PIX_FMT_NV12 -#endif - - enum { DECODE_MAXSZ = 524288, }; @@ -37,6 +30,7 @@ struct viddec_state { size_t frag_start; bool frag; uint16_t frag_seq; + double fps; struct { unsigned n_key; @@ -192,7 +186,9 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) ret = avcodec_send_packet(st->ctx, &avpkt); if (ret < 0) { - warning("avcodec_send_packet error ret=%d\n", ret); + warning("avcodec: avcodec_send_packet error," + " packet=%zu bytes, ret=%d (%s)\n", + st->mb->end, ret, av_err2str(ret)); err = EBADMSG; goto out; } @@ -235,6 +231,8 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) if (got_picture) { + double fps; + #if LIBAVCODEC_VERSION_INT >= ((53<<16)+(5<<8)+0) switch (st->pict->format) { @@ -247,6 +245,10 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) frame->fmt = VID_FMT_NV12; break; + case AV_PIX_FMT_YUV444P: + frame->fmt = VID_FMT_YUV444P; + break; + default: warning("avcodec: decode: bad pixel format" " (%i) (%s)\n", @@ -264,6 +266,18 @@ static int ffdecode(struct viddec_state *st, struct vidframe *frame) } frame->size.w = st->ctx->width; frame->size.h = st->ctx->height; + +#if LIBAVCODEC_VERSION_INT > ((56<<16)+(1<<8)+0) + /* get the framerate of the decoded bitstream */ + fps = av_q2d(st->ctx->framerate); + if (st->fps != fps) { + st->fps = fps; + debug("avcodec: current decoder framerate" + " is %.2f fps\n", fps); + } +#else + (void)fps; +#endif } out: @@ -285,10 +299,11 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, return err; #if 0 - re_printf("avcodec: decode: %s %s type=%2d \n", + re_printf("avcodec: decode: %s %s type=%2d %s \n", marker ? "[M]" : " ", h264_is_keyframe(h264_hdr.type) ? "<KEY>" : " ", - h264_hdr.type); + h264_hdr.type, + h264_nalunit_name(h264_hdr.type)); #endif if (h264_hdr.f) { @@ -329,8 +344,8 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, if (fu.s) { if (st->frag) { - debug("avcodec: lost fragments;" - " ignoring NAL\n"); + debug("avcodec: start: lost fragments;" + " ignoring previous NAL\n"); fragment_rewind(st); ++st->stats.n_lost; } @@ -349,7 +364,8 @@ int decode_h264(struct viddec_state *st, struct vidframe *frame, } else { if (!st->frag) { - debug("avcodec: ignoring fragment\n"); + debug("avcodec: ignoring fragment" + " (nal=%u)\n", fu.type); ++st->stats.n_lost; return 0; } |