*/
/**
- * @file libavcodec/mpegvideo.c
+ * @file
* The simplest mpeg encoder (well, it was the simplest!).
*/
#include "libavutil/intmath.h"
+#include "libavcore/imgutils.h"
#include "avcodec.h"
#include "dsputil.h"
+#include "internal.h"
#include "mpegvideo.h"
#include "mpegvideo_common.h"
#include "mjpegenc.h"
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
};
-const uint8_t * const mpeg2_dc_scale_table[4]={
+const uint8_t * const ff_mpeg2_dc_scale_table[4]={
ff_mpeg1_dc_scale_table,
mpeg2_dc_scale_table1,
mpeg2_dc_scale_table2,
}
/**
- * Releases a frame buffer
+ * Release a frame buffer
*/
static void free_frame_buffer(MpegEncContext *s, Picture *pic)
{
}
/**
- * Allocates a frame buffer
+ * Allocate a frame buffer
*/
static int alloc_frame_buffer(MpegEncContext *s, Picture *pic)
{
for(i=0; i<2; i++){
FF_ALLOCZ_OR_GOTO(s->avctx, pic->motion_val_base[i], 2 * (b8_array_size+4) * sizeof(int16_t), fail)
pic->motion_val[i]= pic->motion_val_base[i]+4;
- FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], b8_array_size * sizeof(uint8_t), fail)
+ FF_ALLOCZ_OR_GOTO(s->avctx, pic->ref_index[i], 4*mb_array_size * sizeof(uint8_t), fail)
}
pic->motion_subsample_log2= 3;
}
}
static int init_duplicate_context(MpegEncContext *s, MpegEncContext *base){
+ int y_size = s->b8_stride * (2 * s->mb_height + 1);
+ int c_size = s->mb_stride * (s->mb_height + 1);
+ int yc_size = y_size + 2 * c_size;
int i;
// edge emu needs blocksize + filter length - 1 (=17x17 for halfpel / 21x21 for h264)
for(i=0;i<12;i++){
s->pblocks[i] = &s->block[i];
}
+
+ if (s->out_format == FMT_H263) {
+ /* ac values */
+ FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);
+ s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
+ s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
+ s->ac_val[2] = s->ac_val[1] + c_size;
+ }
+
return 0;
fail:
return -1; //free() through MPV_common_end()
av_freep(&s->me.map);
av_freep(&s->me.score_map);
av_freep(&s->blocks);
+ av_freep(&s->ac_val_base);
s->block= NULL;
}
COPY(dct_error_sum);
COPY(dct_count[0]);
COPY(dct_count[1]);
+ COPY(ac_val_base);
+ COPY(ac_val[0]);
+ COPY(ac_val[1]);
+ COPY(ac_val[2]);
#undef COPY
}
if(s->codec_id == CODEC_ID_MPEG2VIDEO && !s->progressive_sequence)
s->mb_height = (s->height + 31) / 32 * 2;
- else
+ else if (s->codec_id != CODEC_ID_H264)
s->mb_height = (s->height + 15) / 16;
if(s->avctx->pix_fmt == PIX_FMT_NONE){
return -1;
}
- if((s->width || s->height) && avcodec_check_dimensions(s->avctx, s->width, s->height))
+ if((s->width || s->height) && av_image_check_size(s->width, s->height, 0, s->avctx))
return -1;
dsputil_init(&s->dsp, s->avctx);
yc_size = y_size + 2 * c_size;
/* convert fourcc to upper case */
- s->codec_tag= toupper( s->avctx->codec_tag &0xFF)
- + (toupper((s->avctx->codec_tag>>8 )&0xFF)<<8 )
- + (toupper((s->avctx->codec_tag>>16)&0xFF)<<16)
- + (toupper((s->avctx->codec_tag>>24)&0xFF)<<24);
+ s->codec_tag = ff_toupper4(s->avctx->codec_tag);
- s->stream_codec_tag= toupper( s->avctx->stream_codec_tag &0xFF)
- + (toupper((s->avctx->stream_codec_tag>>8 )&0xFF)<<8 )
- + (toupper((s->avctx->stream_codec_tag>>16)&0xFF)<<16)
- + (toupper((s->avctx->stream_codec_tag>>24)&0xFF)<<24);
+ s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame= (AVFrame*)&s->current_picture;
}
}
if (s->out_format == FMT_H263) {
- /* ac values */
- FF_ALLOCZ_OR_GOTO(s->avctx, s->ac_val_base, yc_size * sizeof(int16_t) * 16, fail);
- s->ac_val[0] = s->ac_val_base + s->b8_stride + 1;
- s->ac_val[1] = s->ac_val_base + y_size + s->mb_stride + 1;
- s->ac_val[2] = s->ac_val[1] + c_size;
-
/* cbp values */
FF_ALLOCZ_OR_GOTO(s->avctx, s->coded_block_base, y_size, fail);
s->coded_block= s->coded_block_base + s->b8_stride + 1;
}
av_freep(&s->dc_val_base);
- av_freep(&s->ac_val_base);
av_freep(&s->coded_block_base);
av_freep(&s->mbintra_table);
av_freep(&s->cbp_table);
return -1;
s->current_picture_ptr= pic;
- s->current_picture_ptr->top_field_first= s->top_field_first; //FIXME use only the vars from current_pic
+ //FIXME use only the vars from current_pic
+ s->current_picture_ptr->top_field_first= s->top_field_first;
+ if(s->codec_id == CODEC_ID_MPEG1VIDEO || s->codec_id == CODEC_ID_MPEG2VIDEO) {
+ if(s->picture_structure != PICT_FRAME)
+ s->current_picture_ptr->top_field_first= (s->picture_structure == PICT_TOP_FIELD) == s->first_field;
+ }
s->current_picture_ptr->interlaced_frame= !s->progressive_frame && !s->progressive_sequence;
}
av_log(s->avctx, AV_LOG_DEBUG, "?");
- if(IS_INTERLACED(mb_type) && s->codec_id == CODEC_ID_H264)
+ if(IS_INTERLACED(mb_type))
av_log(s->avctx, AV_LOG_DEBUG, "=");
else
av_log(s->avctx, AV_LOG_DEBUG, " ");
* @param dest_cr chroma cr/v destination pointer
* @param dir direction (0->forward, 1->backward)
* @param ref_picture array[3] of pointers to the 3 planes of the reference picture
- * @param pic_op halfpel motion compensation function (average or put normally)
+ * @param pix_op halfpel motion compensation function (average or put normally)
* the motion vectors are taken from s->mv and the MV type from s->mv_type
*/
static inline void MPV_motion_lowres(MpegEncContext *s,