#define FFMPEG_VERSION_INT 0x000409
#define FFMPEG_VERSION "0.4.9-pre1"
-#define LIBAVCODEC_BUILD 4724
+#define LIBAVCODEC_BUILD 4725
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
int frame_rate;
/**
- * width / height.
+ * picture width / height.
* - encoding: MUST be set by user.
- * - decoding: set by user if known, codec should override / dynamically change if needed
+ * - decoding: set by lavc.
+ * Note, for compatibility its possible to set this instead of
+ * coded_width/height before decoding
*/
int width, height;
* - decoding: set by user
*/
int lowres;
+
+ /**
+ * bistream width / height. may be different from width/height if lowres
+ * or other things are used
+ * - encoding: unused
+ * - decoding: set by user before init if known, codec should override / dynamically change if needed
+ */
+ int coded_width, coded_height;
} AVCodecContext;
int avpicture_get_size(int pix_fmt, int width, int height);
void avcodec_get_chroma_sub_sample(int pix_fmt, int *h_shift, int *v_shift);
const char *avcodec_get_pix_fmt_name(int pix_fmt);
+void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
enum PixelFormat avcodec_get_pix_fmt(const char* name);
#define FF_LOSS_RESOLUTION 0x0001 /* loss due to resolution change */
MPV_decode_defaults(s);
s->avctx = avctx;
- s->width = s->avctx->width >> avctx->lowres;
- s->height = s->avctx->height >> avctx->lowres;
+ s->width = s->avctx->coded_width;
+ s->height = s->avctx->coded_height;
s->codec_id = s->avctx->codec->id;
s->out_format = FMT_H261;
return -1;
}
- if (s->width >> avctx->lowres != avctx->width || s->height >> avctx->lowres != avctx->height){
+ if (s->width != avctx->coded_width || s->height != avctx->coded_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->lowres;
- avctx->height = s->height >> avctx->lowres;
+ avcodec_set_dimensions(avctx, s->width, s->height);
goto retry;
}
s->avctx = avctx;
s->out_format = FMT_H263;
- s->width = avctx->width;
- s->height = avctx->height;
- avctx->width = -((-s->width )>>avctx->lowres);
- avctx->height= -((-s->height)>>avctx->lowres);
+ s->width = avctx->coded_width;
+ s->height = avctx->coded_height;
s->workaround_bugs= avctx->workaround_bugs;
// set defaults
/* FIXME: By the way H263 decoder is evolving it should have */
/* an H263EncContext */
- if ( -((-s->width )>>avctx->lowres) != avctx->width
- || -((-s->height)>>avctx->lowres) != avctx->height) {
+ if ( s->width != avctx->coded_width
+ || s->height != avctx->coded_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;
s->parse_context= pc;
}
if (!s->context_initialized) {
- avctx->width = -((-s->width)>>avctx->lowres);
- avctx->height = -((-s->height)>>avctx->lowres);
+ avcodec_set_dimensions(avctx, s->width, s->height);
goto retry;
}
dsputil_init(&a->dsp, avctx);
- a->mb_width = (avctx->width + 15) / 16;
- a->mb_height = (avctx->height + 15) / 16;
+ a->mb_width = (avctx->coded_width + 15) / 16;
+ a->mb_height = (avctx->coded_height + 15) / 16;
avctx->coded_frame= (AVFrame*)&a->picture;
a->avctx= 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));
return -1;
s->start_code = -1;
s->first_picture = 1;
- s->org_height = avctx->height << avctx->lowres;
+ s->org_height = avctx->coded_height;
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);
s->width = width;
s->height = height;
- s->avctx->width = -((-s->width )>>s->avctx->lowres);
- s->avctx->height = -((-s->height)>>s->avctx->lowres);
+ avcodec_set_dimensions(s->avctx, width, height);
/* test interlaced mode */
if (s->first_picture &&
j += sizeof(sp5x_data_dht);
memcpy(recoded+j, &sp5x_data_sof[0], sizeof(sp5x_data_sof));
- 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;
+ recoded[j+5] = (avctx->coded_height >> 8) & 0xFF;
+ recoded[j+6] = avctx->coded_height & 0xFF;
+ recoded[j+7] = (avctx->coded_width >> 8) & 0xFF;
+ recoded[j+8] = avctx->coded_width & 0xFF;
j += sizeof(sp5x_data_sof);
memcpy(recoded+j, &sp5x_data_sos[0], sizeof(sp5x_data_sos));
#else
/* SOF */
s->bits = 8;
- s->width = avctx->width;
- s->height = avctx->height;
- avctx->width = -((-avctx->width )>>avctx->lowres);
- avctx->height = -((-avctx->height)>>avctx->lowres);
+ s->width = avctx->coded_width;
+ s->height = avctx->coded_height;
s->nb_components = 3;
s->component_id[0] = 0;
s->h_count[0] = 2;
if (
(s1->mpeg_enc_ctx_allocated == 0)||
- avctx->width != -((-s->width )>>avctx->lowres) ||
- avctx->height != -((-s->height)>>avctx->lowres) ||
+ avctx->coded_width != s->width ||
+ avctx->coded_height != s->height||
// s1->save_aspect_info != avctx->aspect_ratio_info||
0)
{
if( (s->width == 0 )||(s->height == 0))
return -2;
- avctx->width = -((-s->width )>>avctx->lowres);
- avctx->height = -((-s->height)>>avctx->lowres);
+ avcodec_set_dimensions(avctx, s->width, s->height);
avctx->bit_rate = s->bit_rate;
s1->save_aspect_info = s->aspect_ratio_info;
if (s1->mpeg_enc_ctx_allocated) {
MPV_common_end(s);
}
- s->width = avctx->width;
- s->height = avctx->height;
+ s->width = avctx->coded_width;
+ s->height = avctx->coded_height;
avctx->has_b_frames= 0; //true?
s->low_delay= 1;
if (bytes_left >= 4) {
pc->width = (buf[0] << 4) | (buf[1] >> 4);
pc->height = ((buf[1] & 0x0f) << 8) | buf[2];
- avctx->width = -((-pc->width )>>avctx->lowres);
- avctx->height = -((-pc->height)>>avctx->lowres);
+ avcodec_set_dimensions(avctx, pc->width, pc->height);
frame_rate_index = buf[3] & 0xf;
pc->frame_rate = avctx->frame_rate = frame_rate_tab[frame_rate_index];
avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE;
pc->width |=(horiz_size_ext << 12);
pc->height |=( vert_size_ext << 12);
- avctx->width = -((-pc->width )>>avctx->lowres);
- avctx->height = -((-pc->height)>>avctx->lowres);
+ avcodec_set_dimensions(avctx, pc->width, pc->height);
avctx->frame_rate = pc->frame_rate * (frame_rate_ext_n + 1);
avctx->frame_rate_base = MPEG1_FRAME_RATE_BASE * (frame_rate_ext_d + 1);
avctx->codec_id = CODEC_ID_MPEG2VIDEO;
init_get_bits(gb, buf, 8 * buf_size);
ret = ff_mpeg4_decode_picture_header(s, gb);
if (s->width) {
- avctx->width = -((-s->width )>>avctx->lowres);
- avctx->height = -((-s->height)>>avctx->lowres);
+ avcodec_set_dimensions(avctx, s->width, s->height);
}
pc->first_picture = 0;
return ret;
format->next = NULL;
}
+void avcodec_set_dimensions(AVCodecContext *s, int width, int height){
+ s->coded_width = width;
+ s->coded_height= height;
+ s->width = -((-width )>>s->lowres);
+ s->height= -((-height)>>s->lowres);
+}
+
typedef struct InternalBuffer{
int last_pic_num;
uint8_t *base[4];
} else {
avctx->priv_data = NULL;
}
+
+ if(avctx->coded_width && avctx->coded_height)
+ avcodec_set_dimensions(avctx, avctx->coded_width, avctx->coded_height);
+ else if(avctx->width && avctx->height)
+ avcodec_set_dimensions(avctx, avctx->width, avctx->height);
+
ret = avctx->codec->init(avctx);
if (ret < 0) {
av_freep(&avctx->priv_data);