summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-09-27 02:39:55 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-09-27 02:39:55 +0000
commit4f8a831994889f2a90669dc230c14d203d52083d (patch)
treebda1bf3ac88ece871b88a36ff6a4d95eb4ef81a3
parent718455951c74269a95117b117a2790c4edeef979 (diff)
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
-rw-r--r--libavcodec/avcodec.h2
-rw-r--r--libavcodec/h261.c10
-rw-r--r--libavcodec/h263dec.c11
-rw-r--r--libavcodec/mjpeg.c14
-rw-r--r--libavcodec/mpeg12.c8
-rw-r--r--libavcodec/mpegvideo.c12
6 files changed, 32 insertions, 25 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index f5b89953ca..17477032ba 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -17,7 +17,7 @@ extern "C" {
#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 --git a/libavcodec/h261.c b/libavcodec/h261.c
index b9947d0f14..88bd755392 100644
--- a/libavcodec/h261.c
+++ b/libavcodec/h261.c
@@ -118,8 +118,8 @@ static int h261_decode_init(AVCodecContext *avctx){
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 @@ retry:
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 --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 212d538cc3..6ba0564552 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -37,8 +37,10 @@ int ff_h263_decode_init(AVCodecContext *avctx)
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 @@ retry:
/* 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 @@ retry:
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 --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index cb90b410f5..ba056184db 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -859,6 +859,8 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
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 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
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 @@ static int mjpeg_decode_sof(MJpegDecodeContext *s)
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 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
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 @@ static int sp5x_decode_frame(AVCodecContext *avctx,
#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 --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 550f17d154..82a1a80fb5 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1966,8 +1966,8 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
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 @@ static int mpeg_decode_postinit(AVCodecContext *avctx){
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 --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 95c146429e..c89926ff3e 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1720,11 +1720,13 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
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 @@ 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 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 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
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 @@ void ff_print_debug_info(MpegEncContext *s, AVFrame *pict){
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 @@ void ff_draw_horiz_band(MpegEncContext *s, int y, int h){
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;