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). --- core/mplayer.c | 19 +++++++++---------- video/decode/dec_video.c | 4 +--- video/decode/dec_video.h | 3 +-- video/decode/vd.h | 3 +-- video/decode/vd_lavc.c | 17 ++++++++--------- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/core/mplayer.c b/core/mplayer.c index 1a79213bdc..5707fdacc6 100644 --- a/core/mplayer.c +++ b/core/mplayer.c @@ -2437,9 +2437,13 @@ static double update_video_nocorrect_pts(struct MPContext *mpctx) update_fps(mpctx); int framedrop_type = check_framedrop(mpctx, frame_time); - void *decoded_frame; - decoded_frame = decode_video(sh_video, sh_video->ds->current, packet, - in_size, framedrop_type, sh_video->pts); + struct demux_packet pkt = {0}; + if (sh_video->ds->current) + pkt = *sh_video->ds->current; + pkt.buffer = packet; + pkt.len = in_size; + void *decoded_frame = decode_video(sh_video, &pkt, framedrop_type, + sh_video->pts); if (decoded_frame) { filter_video(mpctx, decoded_frame); } @@ -2495,8 +2499,6 @@ static double update_video(struct MPContext *mpctx) break; if (filter_output_queued_frame(mpctx)) break; - int in_size = 0; - unsigned char *buf = NULL; pts = MP_NOPTS_VALUE; struct demux_packet *pkt; while (1) { @@ -2507,11 +2509,8 @@ static double update_video(struct MPContext *mpctx) * but to indicate the absence of a frame in formats like AVI * that must have packets at fixed timecode intervals. */ } - if (pkt) { - in_size = pkt->len; - buf = pkt->buffer; + if (pkt) pts = pkt->pts; - } if (pts != MP_NOPTS_VALUE) pts += mpctx->video_offset; if (pts >= mpctx->hrseek_pts - .005) @@ -2519,7 +2518,7 @@ static double update_video(struct MPContext *mpctx) int framedrop_type = mpctx->hrseek_framedrop ? 1 : check_framedrop(mpctx, sh_video->frametime); struct mp_image *decoded_frame = - decode_video(sh_video, pkt, buf, in_size, framedrop_type, pts); + decode_video(sh_video, pkt, framedrop_type, pts); if (decoded_frame) { determine_frame_pts(mpctx); filter_video(mpctx, decoded_frame); 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