summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2011-07-09 14:14:38 +0300
committerUoti Urpala <uau@mplayer2.org>2011-07-09 14:14:38 +0300
commit13151d7b69974a600873e8513d1d509338b34779 (patch)
tree31427fed6d98a49b6d783e5ee395364c4948b159
parent1a7ef3b39c38837b45f87ce8b673da5641289573 (diff)
downloadmpv-13151d7b69974a600873e8513d1d509338b34779.tar.bz2
mpv-13151d7b69974a600873e8513d1d509338b34779.tar.xz
vd_ffmpeg: make "-lavdopts lowres" handling more robust
Remove the copy of the "lowres" field that vd_ffmpeg kept in its private struct and use the value from AVCodecContext directly instead. The copy gave no benefit and it could be set to the wrong value if someone used "-lavdopts o=lowres=X" (which would change the real value but not the copy).
-rw-r--r--libmpcodecs/vd_ffmpeg.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/libmpcodecs/vd_ffmpeg.c b/libmpcodecs/vd_ffmpeg.c
index 630d0c5e02..0a50415f66 100644
--- a/libmpcodecs/vd_ffmpeg.c
+++ b/libmpcodecs/vd_ffmpeg.c
@@ -72,7 +72,6 @@ typedef struct {
int ip_count;
int b_count;
AVRational last_sample_aspect_ratio;
- int lowres;
enum AVDiscard skip_frame;
} vd_ffmpeg_ctx;
@@ -167,7 +166,6 @@ static int init(sh_video_t *sh){
AVCodecContext *avctx;
vd_ffmpeg_ctx *ctx;
AVCodec *lavc_codec;
- int lowres_w=0;
int do_vis_debug= lavc_param->vismv || (lavc_param->debug&(FF_DEBUG_VIS_MB_TYPE|FF_DEBUG_VIS_QP));
init_avcodec();
@@ -268,10 +266,12 @@ static int init(sh_video_t *sh){
avctx->skip_bottom= lavc_param->skip_bottom;
if(lavc_param->lowres_str != NULL)
{
- sscanf(lavc_param->lowres_str, "%d,%d", &ctx->lowres, &lowres_w);
- if(ctx->lowres < 1 || ctx->lowres > 16 || (lowres_w > 0 && avctx->width < lowres_w))
- ctx->lowres = 0;
- avctx->lowres = ctx->lowres;
+ int lowres, lowres_w;
+ sscanf(lavc_param->lowres_str, "%d,%d", &lowres, &lowres_w);
+ if (lowres < 1 || lowres > 16 ||
+ lowres_w > 0 && avctx->width < lowres_w)
+ lowres = 0;
+ avctx->lowres = lowres;
}
avctx->skip_loop_filter = str2AVDiscard(lavc_param->skip_loop_filter_str);
avctx->skip_idct = str2AVDiscard(lavc_param->skip_idct_str);
@@ -428,7 +428,7 @@ static void draw_slice(struct AVCodecContext *s,
int start=0, i;
int width= s->width;
vd_ffmpeg_ctx *ctx = sh->context;
- int skip_stride= ((width << ctx->lowres)+15)>>4;
+ int skip_stride = ((width << s->lowres)+15) >> 4;
uint8_t *skip= &s->coded_frame->mbskip_table[(y>>4)*skip_stride];
int threshold= s->coded_frame->age;
if(s->pict_type!=B_TYPE){
@@ -478,8 +478,8 @@ static int init_vo(sh_video_t *sh, enum PixelFormat pix_fmt){
// if sh->ImageDesc is non-NULL, it means we decode QuickTime(tm) video.
// use dimensions from BIH to avoid black borders at the right and bottom.
if (sh->bih && sh->ImageDesc) {
- width = sh->bih->biWidth >> ctx->lowres;
- height = sh->bih->biHeight >> ctx->lowres;
+ width = sh->bih->biWidth >> avctx->lowres;
+ height = sh->bih->biHeight >> avctx->lowres;
}
// it is possible another vo buffers to be used after vo config()
@@ -810,8 +810,8 @@ static struct mp_image *decode(struct sh_video *sh, void *data, int len,
// average MB quantizer
{
int x, y;
- int w = ((avctx->width << ctx->lowres)+15) >> 4;
- int h = ((avctx->height << ctx->lowres)+15) >> 4;
+ int w = ((avctx->width << avctx->lowres)+15) >> 4;
+ int h = ((avctx->height << avctx->lowres)+15) >> 4;
int8_t *q = pic->qscale_table;
for(y = 0; y < h; y++) {
for(x = 0; x < w; x++)