From 3374a43998f183b585640de0a588db2431ed87ae Mon Sep 17 00:00:00 2001 From: wm4 Date: Thu, 28 Mar 2013 20:16:11 +0100 Subject: core: always pass data via packet fields to video decoders Makes the code a bit simpler to follow, at least in the "modern" decoding path (update_video_nocorrect_pts() is used with old demuxers, which don't return proper packets and need further parsing, so this code looks less simple now). --- video/decode/dec_video.c | 4 +--- video/decode/dec_video.h | 3 +-- video/decode/vd.h | 3 +-- video/decode/vd_lavc.c | 17 ++++++++--------- 4 files changed, 11 insertions(+), 16 deletions(-) (limited to 'video') diff --git a/video/decode/dec_video.c b/video/decode/dec_video.c index 9888881e26..465791a1ed 100644 --- a/video/decode/dec_video.c +++ b/video/decode/dec_video.c @@ -275,7 +275,6 @@ int init_best_video_codec(sh_video_t *sh_video, char* video_decoders) } void *decode_video(sh_video_t *sh_video, struct demux_packet *packet, - unsigned char *start, int in_size, int drop_frame, double pts) { mp_image_t *mpi = NULL; @@ -311,8 +310,7 @@ void *decode_video(sh_video_t *sh_video, struct demux_packet *packet, } } - mpi = sh_video->vd_driver->decode(sh_video, packet, start, in_size, - drop_frame, &pts); + mpi = sh_video->vd_driver->decode(sh_video, packet, drop_frame, &pts); //------------------------ frame decoded. -------------------- diff --git a/video/decode/dec_video.h b/video/decode/dec_video.h index b6b85e86f6..94bd2bce3a 100644 --- a/video/decode/dec_video.h +++ b/video/decode/dec_video.h @@ -31,8 +31,7 @@ void uninit_video(sh_video_t *sh_video); struct demux_packet; void *decode_video(sh_video_t *sh_video, struct demux_packet *packet, - unsigned char *start, int in_size, int drop_frame, - double pts); + int drop_frame, double pts); int get_video_quality_max(sh_video_t *sh_video); diff --git a/video/decode/vd.h b/video/decode/vd.h index c4c2b7f465..88ce4b2f59 100644 --- a/video/decode/vd.h +++ b/video/decode/vd.h @@ -34,8 +34,7 @@ typedef struct vd_functions void (*uninit)(sh_video_t *sh); int (*control)(sh_video_t *sh, int cmd, void *arg); struct mp_image *(*decode)(struct sh_video *sh, struct demux_packet *pkt, - void *data, int len, int flags, - double *reordered_pts); + int flags, double *reordered_pts); } vd_functions_t; // NULL terminated array of all drivers diff --git a/video/decode/vd_lavc.c b/video/decode/vd_lavc.c index 9e334334cc..dfca042ba0 100644 --- a/video/decode/vd_lavc.c +++ b/video/decode/vd_lavc.c @@ -636,9 +636,8 @@ static struct mp_image *image_from_decoder(struct sh_video *sh) #endif /* HAVE_AVUTIL_REFCOUNTING */ -static int decode(struct sh_video *sh, struct demux_packet *packet, void *data, - int len, int flags, double *reordered_pts, - struct mp_image **out_image) +static int decode(struct sh_video *sh, struct demux_packet *packet, + int flags, double *reordered_pts, struct mp_image **out_image) { int got_picture = 0; int ret; @@ -655,8 +654,8 @@ static int decode(struct sh_video *sh, struct demux_packet *packet, void *data, avctx->skip_frame = ctx->skip_frame; av_init_packet(&pkt); - pkt.data = data; - pkt.size = len; + pkt.data = packet ? packet->buffer : NULL; + pkt.size = packet ? packet->len : 0; /* Some codecs (ZeroCodec, some cases of PNG) may want keyframe info * from demuxer. */ if (packet && packet->keyframe) @@ -692,15 +691,15 @@ static int decode(struct sh_video *sh, struct demux_packet *packet, void *data, } static struct mp_image *decode_with_fallback(struct sh_video *sh, - struct demux_packet *packet, void *data, - int len, int flags, double *reordered_pts) + struct demux_packet *packet, + int flags, double *reordered_pts) { vd_ffmpeg_ctx *ctx = sh->context; if (!ctx->avctx) return NULL; struct mp_image *mpi = NULL; - int res = decode(sh, packet, data, len, flags, reordered_pts, &mpi); + int res = decode(sh, packet, flags, reordered_pts, &mpi); if (res >= 0) return mpi; @@ -714,7 +713,7 @@ static struct mp_image *decode_with_fallback(struct sh_video *sh, ctx->software_fallback_decoder = NULL; if (init_avctx(sh, decoder, NULL)) { mpi = NULL; - decode(sh, packet, data, len, flags, reordered_pts, &mpi); + decode(sh, packet, flags, reordered_pts, &mpi); return mpi; } } -- cgit v1.2.3