# HG changeset patch # User michael # Date 1096252795 0 # Node ID 514949de5d15a0a1fd4dee1ac6e60562b5e15f91 # Parent c93da911905ea64e53162a8519657375af4272ca set AVCodecContext.width/height to the picture width/height instead of the one stored in the bitstream (that only matters if lowres!=0) diff -r c93da911905e -r 514949de5d15 avcodec.h --- a/avcodec.h Sun Sep 26 23:01:42 2004 +0000 +++ b/avcodec.h Mon Sep 27 02:39:55 2004 +0000 @@ -17,7 +17,7 @@ #define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION "0.4.9-pre1" -#define LIBAVCODEC_BUILD 4723 +#define LIBAVCODEC_BUILD 4724 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT #define LIBAVCODEC_VERSION FFMPEG_VERSION diff -r c93da911905e -r 514949de5d15 h261.c --- a/h261.c Sun Sep 26 23:01:42 2004 +0000 +++ b/h261.c Mon Sep 27 02:39:55 2004 +0000 @@ -118,8 +118,8 @@ MPV_decode_defaults(s); s->avctx = avctx; - s->width = s->avctx->width; - s->height = s->avctx->height; + s->width = s->avctx->width >> avctx->lowres; + s->height = s->avctx->height >> avctx->lowres; s->codec_id = s->avctx->codec->id; s->out_format = FMT_H261; @@ -715,15 +715,15 @@ return -1; } - if (s->width != avctx->width || s->height != avctx->height){ + if (s->width >> avctx->lowres != avctx->width || s->height >> avctx->lowres != avctx->height){ ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat s->parse_context.buffer=0; MPV_common_end(s); s->parse_context= pc; } if (!s->context_initialized) { - avctx->width = s->width; - avctx->height = s->height; + avctx->width = s->width >> avctx->lowres; + avctx->height = s->height >> avctx->lowres; goto retry; } diff -r c93da911905e -r 514949de5d15 h263dec.c --- a/h263dec.c Sun Sep 26 23:01:42 2004 +0000 +++ b/h263dec.c Mon Sep 27 02:39:55 2004 +0000 @@ -37,8 +37,10 @@ s->avctx = avctx; s->out_format = FMT_H263; - s->width = avctx->width; + s->width = avctx->width; s->height = avctx->height; + avctx->width = -((-s->width )>>avctx->lowres); + avctx->height= -((-s->height)>>avctx->lowres); s->workaround_bugs= avctx->workaround_bugs; // set defaults @@ -637,7 +639,8 @@ /* FIXME: By the way H263 decoder is evolving it should have */ /* an H263EncContext */ - if ( s->width != avctx->width || s->height != avctx->height) { + if ( -((-s->width )>>avctx->lowres) != avctx->width + || -((-s->height)>>avctx->lowres) != avctx->height) { /* H.263 could change picture size any time */ ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat s->parse_context.buffer=0; @@ -645,8 +648,8 @@ s->parse_context= pc; } if (!s->context_initialized) { - avctx->width = s->width; - avctx->height = s->height; + avctx->width = -((-s->width)>>avctx->lowres); + avctx->height = -((-s->height)>>avctx->lowres); goto retry; } diff -r c93da911905e -r 514949de5d15 mjpeg.c --- a/mjpeg.c Sun Sep 26 23:01:42 2004 +0000 +++ b/mjpeg.c Mon Sep 27 02:39:55 2004 +0000 @@ -859,6 +859,8 @@ MpegEncContext s2; s->avctx = avctx; + avctx->width = -((-avctx->width )) >> avctx->lowres; + avctx->height= -((-avctx->height)) >> avctx->lowres; /* ugly way to get the idct & scantable FIXME */ memset(&s2, 0, sizeof(MpegEncContext)); @@ -878,7 +880,7 @@ return -1; s->start_code = -1; s->first_picture = 1; - s->org_height = avctx->height; + s->org_height = avctx->height << avctx->lowres; build_vlc(&s->vlcs[0][0], bits_dc_luminance, val_dc_luminance, 12); build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12); @@ -1030,8 +1032,8 @@ s->width = width; s->height = height; - s->avctx->width = s->width; - s->avctx->height = s->height; + s->avctx->width = -((-s->width )>>s->avctx->lowres); + s->avctx->height = -((-s->height)>>s->avctx->lowres); /* test interlaced mode */ if (s->first_picture && @@ -2041,7 +2043,7 @@ j += sizeof(sp5x_data_dht); memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof)); - recoded[j+5] = (avctx->height >> 8) & 0xFF; + recoded[j+5] = (avctx->height >> 8) & 0xFF; //FIXME lowres recoded[j+6] = avctx->height & 0xFF; recoded[j+7] = (avctx->width >> 8) & 0xFF; recoded[j+8] = avctx->width & 0xFF; @@ -2068,8 +2070,8 @@ #else /* SOF */ s->bits = 8; - s->width = avctx->width; - s->height = avctx->height; + s->width = avctx->width << avctx->lowres; + s->height = avctx->height<< avctx->lowres; s->nb_components = 3; s->component_id[0] = 0; s->h_count[0] = 2; diff -r c93da911905e -r 514949de5d15 mpeg12.c --- a/mpeg12.c Sun Sep 26 23:01:42 2004 +0000 +++ b/mpeg12.c Mon Sep 27 02:39:55 2004 +0000 @@ -1966,8 +1966,8 @@ if ( (s1->mpeg_enc_ctx_allocated == 0)|| - avctx->width != s->width || - avctx->height != s->height|| + avctx->width != -((-s->width )>>avctx->lowres) || + avctx->height != -((-s->height)>>avctx->lowres) || // s1->save_aspect_info != avctx->aspect_ratio_info|| 0) { @@ -1979,8 +1979,8 @@ if( (s->width == 0 )||(s->height == 0)) return -2; - avctx->width = s->width; - avctx->height = s->height; + avctx->width = -((-s->width )>>avctx->lowres); + avctx->height = -((-s->height)>>avctx->lowres); avctx->bit_rate = s->bit_rate; s1->save_aspect_info = s->aspect_ratio_info; diff -r c93da911905e -r 514949de5d15 mpegvideo.c --- a/mpegvideo.c Sun Sep 26 23:01:42 2004 +0000 +++ b/mpegvideo.c Mon Sep 27 02:39:55 2004 +0000 @@ -1720,11 +1720,13 @@ uint8_t *ptr; int i; int h_chroma_shift, v_chroma_shift; + const int width = s->avctx->width; + const int height= s->avctx->height; s->low_delay=0; //needed to see the vectors without trashing the buffers avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift); for(i=0; i<3; i++){ - memcpy(s->visualization_buffer[i], pict->data[i], (i==0) ? pict->linesize[i]*s->height:pict->linesize[i]*s->height >> v_chroma_shift); + memcpy(s->visualization_buffer[i], pict->data[i], (i==0) ? pict->linesize[i]*height:pict->linesize[i]*height >> v_chroma_shift); pict->data[i]= s->visualization_buffer[i]; } pict->type= FF_BUFFER_TYPE_COPY; @@ -1764,7 +1766,7 @@ int xy= mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride; int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; int my= (pict->motion_val[direction][xy][1]>>shift) + sy; - draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); + draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); } }else if(IS_16X8(pict->mb_type[mb_index])){ int i; @@ -1778,7 +1780,7 @@ if(IS_INTERLACED(pict->mb_type[mb_index])) my*=2; - draw_arrow(ptr, sx, sy, mx+sx, my+sy, s->width, s->height, s->linesize, 100); + draw_arrow(ptr, sx, sy, mx+sx, my+sy, width, height, s->linesize, 100); } }else{ int sx= mb_x*16 + 8; @@ -1786,7 +1788,7 @@ int xy= mb_x*2 + mb_y*2*s->b8_stride; int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; int my= (pict->motion_val[direction][xy][1]>>shift) + sy; - draw_arrow(ptr, sx, sy, mx, my, s->width, s->height, s->linesize, 100); + draw_arrow(ptr, sx, sy, mx, my, width, height, s->linesize, 100); } } } @@ -3702,7 +3704,7 @@ if(s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return; } - h= FFMIN(h, (s->height>>s->avctx->lowres) - y); + h= FFMIN(h, s->avctx->height - y); if(s->pict_type==B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) src= (AVFrame*)s->current_picture_ptr;