*/
/**
- * @file libavcodec/mpegvideo.c
+ * @file
* The simplest mpeg encoder (well, it was the simplest!).
*/
+#include "libavutil/intmath.h"
#include "avcodec.h"
#include "dsputil.h"
+#include "internal.h"
#include "mpegvideo.h"
#include "mpegvideo_common.h"
#include "mjpegenc.h"
8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
};
+static const uint8_t mpeg2_dc_scale_table1[128]={
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
+};
+
+static const uint8_t mpeg2_dc_scale_table2[128]={
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+};
+
+static const uint8_t mpeg2_dc_scale_table3[128]={
+// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
+ 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,
+ 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,
+ 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,
+ 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 ff_mpeg2_dc_scale_table[4]={
+ ff_mpeg1_dc_scale_table,
+ mpeg2_dc_scale_table1,
+ mpeg2_dc_scale_table2,
+ mpeg2_dc_scale_table3,
+};
+
const enum PixelFormat ff_pixfmt_list_420[] = {
PIX_FMT_YUV420P,
PIX_FMT_NONE
}
/**
- * 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->ac_val_base) {
+ 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
}
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->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->codec_tag = ff_toupper4(s->avctx->codec_tag);
+
+ s->stream_codec_tag = ff_toupper4(s->avctx->stream_codec_tag);
s->avctx->coded_frame= (AVFrame*)&s->current_picture;