[Ffmpeg-cvslog] CVS: ffmpeg/libavcodec avcodec.h, 1.465, 1.466 mpeg12.c, 1.252, 1.253 mpegvideo.c, 1.517, 1.518 utils.c, 1.180, 1.181
Baptiste Coudurier CVS
bcoudurier
Sat May 13 19:17:01 CEST 2006
Update of /cvsroot/ffmpeg/ffmpeg/libavcodec
In directory mail:/var2/tmp/cvs-serv9181/libavcodec
Modified Files:
avcodec.h mpeg12.c mpegvideo.c utils.c
Log Message:
add MPEG-2 intra vlc support
Index: avcodec.h
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/avcodec.h,v
retrieving revision 1.465
retrieving revision 1.466
diff -u -d -r1.465 -r1.466
--- avcodec.h 7 May 2006 11:48:07 -0000 1.465
+++ avcodec.h 13 May 2006 17:16:57 -0000 1.466
@@ -341,6 +341,7 @@
#define CODEC_FLAG2_FASTPSKIP 0x00000100 ///< H.264 fast pskip
#define CODEC_FLAG2_AUD 0x00000200 ///< H.264 access unit delimiters
#define CODEC_FLAG2_BRDO 0x00000400 ///< b-frame rate-distortion optimization
+#define CODEC_FLAG2_INTRA_VLC 0x00000800 ///< use MPEG-2 intra VLC table
/* Unsupported options :
* Syntax Arithmetic coding (SAC)
Index: mpeg12.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpeg12.c,v
retrieving revision 1.252
retrieving revision 1.253
diff -u -d -r1.252 -r1.253
--- mpeg12.c 13 May 2006 15:43:51 -0000 1.252
+++ mpeg12.c 13 May 2006 17:16:57 -0000 1.253
@@ -95,6 +95,7 @@
static uint8_t fcode_tab[MAX_MV*2+1];
static uint8_t uni_mpeg1_ac_vlc_len [64*64*2];
+static uint8_t uni_mpeg2_ac_vlc_len [64*64*2];
/* simple include everything table for dc, first byte is bits number next 3 are code*/
static uint32_t mpeg1_lum_dc_uni[512];
@@ -166,11 +167,11 @@
if (code < 111 /* rl->n */) {
/* store the vlc & sign at once */
- len= mpeg1_vlc[code][1]+1;
- bits= (mpeg1_vlc[code][0]<<1) + sign;
+ len= rl->table_vlc[code][1]+1;
+ bits= (rl->table_vlc[code][0]<<1) + sign;
} else {
- len= mpeg1_vlc[111/*rl->n*/][1]+6;
- bits= mpeg1_vlc[111/*rl->n*/][0]<<6;
+ len= rl->table_vlc[111/*rl->n*/][1]+6;
+ bits= rl->table_vlc[111/*rl->n*/][0]<<6;
bits|= run;
if (alevel < 128) {
@@ -766,6 +767,8 @@
done=1;
init_rl(&rl_mpeg1, 1);
+ if(s->intra_vlc_format)
+ init_rl(&rl_mpeg2, 1);
for(i=0; i<64; i++)
{
@@ -774,6 +777,8 @@
}
init_uni_ac_vlc(&rl_mpeg1, uni_mpeg1_ac_vlc_len);
+ if(s->intra_vlc_format)
+ init_uni_ac_vlc(&rl_mpeg2, uni_mpeg2_ac_vlc_len);
/* build unified dc encoding tables */
for(i=-255; i<256; i++)
@@ -840,9 +845,14 @@
s->min_qcoeff=-2047;
s->max_qcoeff= 2047;
}
- s->intra_ac_vlc_length=
+ if (s->intra_vlc_format) {
+ s->intra_ac_vlc_length=
+ s->intra_ac_vlc_last_length= uni_mpeg2_ac_vlc_len;
+ } else {
+ s->intra_ac_vlc_length=
+ s->intra_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
+ }
s->inter_ac_vlc_length=
- s->intra_ac_vlc_last_length=
s->inter_ac_vlc_last_length= uni_mpeg1_ac_vlc_len;
}
@@ -889,7 +899,7 @@
{
int alevel, level, last_non_zero, dc, diff, i, j, run, last_index, sign;
int code, component;
-// RLTable *rl = &rl_mpeg1;
+ const uint16_t (*table_vlc)[2] = rl_mpeg1.table_vlc;
last_index = s->block_last_index[n];
@@ -901,12 +911,8 @@
encode_dc(s, diff, component);
s->last_dc[component] = dc;
i = 1;
-/*
if (s->intra_vlc_format)
- rl = &rl_mpeg2;
- else
- rl = &rl_mpeg1;
-*/
+ table_vlc = rl_mpeg2.table_vlc;
} else {
/* encode the first coefficient : needs to be done here because
it is handled slightly differently */
@@ -941,14 +947,13 @@
MASK_ABS(sign, alevel)
sign&=1;
-// code = get_rl_index(rl, 0, run, alevel);
if (alevel <= mpeg1_max_level[0][run]){
code= mpeg1_index_run[0][run] + alevel - 1;
/* store the vlc & sign at once */
- put_bits(&s->pb, mpeg1_vlc[code][1]+1, (mpeg1_vlc[code][0]<<1) + sign);
+ put_bits(&s->pb, table_vlc[code][1]+1, (table_vlc[code][0]<<1) + sign);
} else {
/* escape seems to be pretty rare <5% so i dont optimize it */
- put_bits(&s->pb, mpeg1_vlc[111/*rl->n*/][1], mpeg1_vlc[111/*rl->n*/][0]);
+ put_bits(&s->pb, table_vlc[111][1], table_vlc[111][0]);
/* escape: only clip in this case */
put_bits(&s->pb, 6, run);
if(s->codec_id == CODEC_ID_MPEG1VIDEO){
@@ -969,7 +974,7 @@
}
}
/* end of block */
- put_bits(&s->pb, 2, 0x2);
+ put_bits(&s->pb, table_vlc[112][1], table_vlc[112][0]);
}
#endif //CONFIG_ENCODERS
Index: mpegvideo.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/mpegvideo.c,v
retrieving revision 1.517
retrieving revision 1.518
diff -u -d -r1.517 -r1.518
--- mpegvideo.c 9 May 2006 08:40:38 -0000 1.517
+++ mpegvideo.c 13 May 2006 17:16:57 -0000 1.518
@@ -991,6 +991,7 @@
s->obmc= !!(s->flags & CODEC_FLAG_OBMC);
s->loop_filter= !!(s->flags & CODEC_FLAG_LOOP_FILTER);
s->alternate_scan= !!(s->flags & CODEC_FLAG_ALT_SCAN);
+ s->intra_vlc_format= !!(s->flags2 & CODEC_FLAG2_INTRA_VLC);
if(avctx->rc_max_rate && !avctx->rc_buffer_size){
av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
@@ -1075,6 +1076,11 @@
return -1;
}
+ if((s->flags2 & CODEC_FLAG2_INTRA_VLC) && s->codec_id != CODEC_ID_MPEG2VIDEO){
+ av_log(avctx, AV_LOG_ERROR, "intra vlc table not supported by codec\n");
+ return -1;
+ }
+
if(s->avctx->thread_count > 1 && s->codec_id != CODEC_ID_MPEG4
&& s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO
&& (s->codec_id != CODEC_ID_H263P || !(s->flags & CODEC_FLAG_H263P_SLICE_STRUCT))){
Index: utils.c
===================================================================
RCS file: /cvsroot/ffmpeg/ffmpeg/libavcodec/utils.c,v
retrieving revision 1.180
retrieving revision 1.181
diff -u -d -r1.180 -r1.181
--- utils.c 7 May 2006 11:48:07 -0000 1.180
+++ utils.c 13 May 2006 17:16:57 -0000 1.181
@@ -740,6 +740,7 @@
{"partb8x8", NULL, 0, FF_OPT_TYPE_CONST, X264_PART_B8X8, INT_MIN, INT_MAX, V|E, "partitions"},
{"sc_factor", NULL, OFFSET(scenechange_factor), FF_OPT_TYPE_INT, 6, 0, INT_MAX, V|E},
{"mv0_threshold", NULL, OFFSET(mv0_threshold), FF_OPT_TYPE_INT, 256, 0, INT_MAX, V|E},
+{"ivlc", "intra vlc table", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_INTRA_VLC, INT_MIN, INT_MAX, V|E, "flags2"},
{NULL},
};
More information about the ffmpeg-cvslog
mailing list