summaryrefslogtreecommitdiffstats
path: root/libmpcodecs/vd_ffmpeg.c
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-11-14 20:12:20 +0200
committerUoti Urpala <uau@mplayer2.org>2011-11-14 20:24:39 +0200
commit3a39fc1feabf24a07084b4e1f68129c492e5d54a (patch)
tree9c2526b9dfb350b54bbc063870584b5d713cf2b7 /libmpcodecs/vd_ffmpeg.c
parent7b9908dda875db404604e87c8b762784d4f774d1 (diff)
downloadmpv-3a39fc1feabf24a07084b4e1f68129c492e5d54a.tar.bz2
mpv-3a39fc1feabf24a07084b4e1f68129c492e5d54a.tar.xz
commands, vd_ffmpeg: fix switch_ratio slave command
The implementation of the switch_ratio command was hacky and called mpcodecs_config_vo() to reconfigure the filter/VO chain from under an existing decoder. This call no longer worked properly with vd_ffmpeg after that started using mpcodec_config_vo2(). Add new video decoder control command VDCTRL_RESET_ASPECT and use this to tell vd_ffmpeg to reinitialize the output chain properly.
Diffstat (limited to 'libmpcodecs/vd_ffmpeg.c')
-rw-r--r--libmpcodecs/vd_ffmpeg.c72
1 files changed, 38 insertions, 34 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 21c107587d..b7f189ec5f 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -119,40 +119,6 @@ static enum AVDiscard str2AVDiscard(char *str)
return AVDISCARD_DEFAULT;
}
-static int control(sh_video_t *sh, int cmd, void *arg, ...)
-{
- vd_ffmpeg_ctx *ctx = sh->context;
- AVCodecContext *avctx = ctx->avctx;
- switch (cmd) {
- case VDCTRL_QUERY_FORMAT:
- {
- int format = (*((int *)arg));
- if (format == ctx->best_csp)
- return CONTROL_TRUE;
- // possible conversions:
- switch (format) {
- case IMGFMT_YV12:
- case IMGFMT_IYUV:
- case IMGFMT_I420:
- // "converted" using pointer/stride modification
- if (ctx->best_csp == IMGFMT_YV12)
- return CONTROL_TRUE; // u/v swap
- if (ctx->best_csp == IMGFMT_422P && !ctx->do_dr1)
- return CONTROL_TRUE; // half stride
- break;
- }
- return CONTROL_FALSE;
- }
- case VDCTRL_RESYNC_STREAM:
- avcodec_flush_buffers(avctx);
- return CONTROL_TRUE;
- case VDCTRL_QUERY_UNSEEN_FRAMES:;
- int delay = avctx->has_b_frames;
- return delay + 10;
- }
- return CONTROL_UNKNOWN;
-}
-
static int init(sh_video_t *sh)
{
struct lavc_param *lavc_param = &sh->opts->lavc_param;
@@ -864,6 +830,44 @@ static enum PixelFormat get_format(struct AVCodecContext *avctx,
return fmt[i];
}
+static int control(sh_video_t *sh, int cmd, void *arg, ...)
+{
+ vd_ffmpeg_ctx *ctx = sh->context;
+ AVCodecContext *avctx = ctx->avctx;
+ switch (cmd) {
+ case VDCTRL_QUERY_FORMAT: {
+ int format = (*((int *)arg));
+ if (format == ctx->best_csp)
+ return CONTROL_TRUE;
+ // possible conversions:
+ switch (format) {
+ case IMGFMT_YV12:
+ case IMGFMT_IYUV:
+ case IMGFMT_I420:
+ // "converted" using pointer/stride modification
+ if (ctx->best_csp == IMGFMT_YV12)
+ return CONTROL_TRUE; // u/v swap
+ if (ctx->best_csp == IMGFMT_422P && !ctx->do_dr1)
+ return CONTROL_TRUE; // half stride
+ break;
+ }
+ return CONTROL_FALSE;
+ }
+ case VDCTRL_RESYNC_STREAM:
+ avcodec_flush_buffers(avctx);
+ return CONTROL_TRUE;
+ case VDCTRL_QUERY_UNSEEN_FRAMES:;
+ int delay = avctx->has_b_frames;
+ return delay + 10;
+ case VDCTRL_RESET_ASPECT:
+ if (ctx->vo_initialized)
+ ctx->vo_initialized = false;
+ init_vo(sh, avctx->pix_fmt);
+ return true;
+ }
+ return CONTROL_UNKNOWN;
+}
+
const struct vd_functions mpcodecs_vd_ffmpeg = {
.info = &info,
.init = init,