set AVCodecContext.width/height to the picture width/height instead of the one stored in the bitstream (that only matters if lowres!=0)

Originally committed as revision 3518 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Michael Niedermayer 2004-09-27 02:39:55 +00:00
parent 718455951c
commit 4f8a831994
6 changed files with 32 additions and 25 deletions

View File

@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000409 #define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1" #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_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION #define LIBAVCODEC_VERSION FFMPEG_VERSION

View File

@ -118,8 +118,8 @@ static int h261_decode_init(AVCodecContext *avctx){
MPV_decode_defaults(s); MPV_decode_defaults(s);
s->avctx = avctx; s->avctx = avctx;
s->width = s->avctx->width; s->width = s->avctx->width >> avctx->lowres;
s->height = s->avctx->height; s->height = s->avctx->height >> avctx->lowres;
s->codec_id = s->avctx->codec->id; s->codec_id = s->avctx->codec->id;
s->out_format = FMT_H261; s->out_format = FMT_H261;
@ -715,15 +715,15 @@ retry:
return -1; 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 ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
s->parse_context.buffer=0; s->parse_context.buffer=0;
MPV_common_end(s); MPV_common_end(s);
s->parse_context= pc; s->parse_context= pc;
} }
if (!s->context_initialized) { if (!s->context_initialized) {
avctx->width = s->width; avctx->width = s->width >> avctx->lowres;
avctx->height = s->height; avctx->height = s->height >> avctx->lowres;
goto retry; goto retry;
} }

View File

@ -37,8 +37,10 @@ int ff_h263_decode_init(AVCodecContext *avctx)
s->avctx = avctx; s->avctx = avctx;
s->out_format = FMT_H263; s->out_format = FMT_H263;
s->width = avctx->width; s->width = avctx->width;
s->height = avctx->height; s->height = avctx->height;
avctx->width = -((-s->width )>>avctx->lowres);
avctx->height= -((-s->height)>>avctx->lowres);
s->workaround_bugs= avctx->workaround_bugs; s->workaround_bugs= avctx->workaround_bugs;
// set defaults // set defaults
@ -637,7 +639,8 @@ retry:
/* FIXME: By the way H263 decoder is evolving it should have */ /* FIXME: By the way H263 decoder is evolving it should have */
/* an H263EncContext */ /* 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 */ /* H.263 could change picture size any time */
ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat ParseContext pc= s->parse_context; //FIXME move these demuxng hack to avformat
s->parse_context.buffer=0; s->parse_context.buffer=0;
@ -645,8 +648,8 @@ retry:
s->parse_context= pc; s->parse_context= pc;
} }
if (!s->context_initialized) { if (!s->context_initialized) {
avctx->width = s->width; avctx->width = -((-s->width)>>avctx->lowres);
avctx->height = s->height; avctx->height = -((-s->height)>>avctx->lowres);
goto retry; goto retry;
} }

View File

@ -859,6 +859,8 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
MpegEncContext s2; MpegEncContext s2;
s->avctx = avctx; s->avctx = avctx;
avctx->width = -((-avctx->width )) >> avctx->lowres;
avctx->height= -((-avctx->height)) >> avctx->lowres;
/* ugly way to get the idct & scantable FIXME */ /* ugly way to get the idct & scantable FIXME */
memset(&s2, 0, sizeof(MpegEncContext)); memset(&s2, 0, sizeof(MpegEncContext));
@ -878,7 +880,7 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
return -1; return -1;
s->start_code = -1; s->start_code = -1;
s->first_picture = 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][0], bits_dc_luminance, val_dc_luminance, 12);
build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12); build_vlc(&s->vlcs[0][1], bits_dc_chrominance, val_dc_chrominance, 12);
@ -1030,8 +1032,8 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
s->width = width; s->width = width;
s->height = height; s->height = height;
s->avctx->width = s->width; s->avctx->width = -((-s->width )>>s->avctx->lowres);
s->avctx->height = s->height; s->avctx->height = -((-s->height)>>s->avctx->lowres);
/* test interlaced mode */ /* test interlaced mode */
if (s->first_picture && if (s->first_picture &&
@ -2041,7 +2043,7 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
j += sizeof(sp5x_data_dht); j += sizeof(sp5x_data_dht);
memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof)); 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+6] = avctx->height & 0xFF;
recoded[j+7] = (avctx->width >> 8) & 0xFF; recoded[j+7] = (avctx->width >> 8) & 0xFF;
recoded[j+8] = avctx->width & 0xFF; recoded[j+8] = avctx->width & 0xFF;
@ -2068,8 +2070,8 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
#else #else
/* SOF */ /* SOF */
s->bits = 8; s->bits = 8;
s->width = avctx->width; s->width = avctx->width << avctx->lowres;
s->height = avctx->height; s->height = avctx->height<< avctx->lowres;
s->nb_components = 3; s->nb_components = 3;
s->component_id[0] = 0; s->component_id[0] = 0;
s->h_count[0] = 2; s->h_count[0] = 2;

View File

@ -1966,8 +1966,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
if ( if (
(s1->mpeg_enc_ctx_allocated == 0)|| (s1->mpeg_enc_ctx_allocated == 0)||
avctx->width != s->width || avctx->width != -((-s->width )>>avctx->lowres) ||
avctx->height != s->height|| avctx->height != -((-s->height)>>avctx->lowres) ||
// s1->save_aspect_info != avctx->aspect_ratio_info|| // s1->save_aspect_info != avctx->aspect_ratio_info||
0) 0)
{ {
@ -1979,8 +1979,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
if( (s->width == 0 )||(s->height == 0)) if( (s->width == 0 )||(s->height == 0))
return -2; return -2;
avctx->width = s->width; avctx->width = -((-s->width )>>avctx->lowres);
avctx->height = s->height; avctx->height = -((-s->height)>>avctx->lowres);
avctx->bit_rate = s->bit_rate; avctx->bit_rate = s->bit_rate;
s1->save_aspect_info = s->aspect_ratio_info; s1->save_aspect_info = s->aspect_ratio_info;

View File

@ -1720,11 +1720,13 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
uint8_t *ptr; uint8_t *ptr;
int i; int i;
int h_chroma_shift, v_chroma_shift; 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 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); avcodec_get_chroma_sub_sample(s->avctx->pix_fmt, &h_chroma_shift, &v_chroma_shift);
for(i=0; i<3; i++){ 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->data[i]= s->visualization_buffer[i];
} }
pict->type= FF_BUFFER_TYPE_COPY; pict->type= FF_BUFFER_TYPE_COPY;
@ -1764,7 +1766,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
int xy= mb_x*2 + (i&1) + (mb_y*2 + (i>>1))*s->b8_stride; 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 mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
int my= (pict->motion_val[direction][xy][1]>>shift) + sy; 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])){ }else if(IS_16X8(pict->mb_type[mb_index])){
int i; int i;
@ -1778,7 +1780,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
if(IS_INTERLACED(pict->mb_type[mb_index])) if(IS_INTERLACED(pict->mb_type[mb_index]))
my*=2; 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{ }else{
int sx= mb_x*16 + 8; int sx= mb_x*16 + 8;
@ -1786,7 +1788,7 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
int xy= mb_x*2 + mb_y*2*s->b8_stride; int xy= mb_x*2 + mb_y*2*s->b8_stride;
int mx= (pict->motion_val[direction][xy][0]>>shift) + sx; int mx= (pict->motion_val[direction][xy][0]>>shift) + sx;
int my= (pict->motion_val[direction][xy][1]>>shift) + sy; 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 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
if(s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return; 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)) if(s->pict_type==B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
src= (AVFrame*)s->current_picture_ptr; src= (AVFrame*)s->current_picture_ptr;