*/
//#define DEBUG
+#include <limits.h>
+
#include "common.h"
#include "dsputil.h"
#include "avcodec.h"
int n, int coded, int intra, int rvlc);
static int h263_pred_dc(MpegEncContext * s, int n, uint16_t **dc_val_ptr);
#ifdef CONFIG_ENCODERS
-static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
- int dir);
static void mpeg4_encode_visual_object_header(MpegEncContext * s);
static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_number);
#endif //CONFIG_ENCODERS
#ifdef CONFIG_ENCODERS
-static void float_aspect_to_info(MpegEncContext * s, float aspect){
+static void aspect_to_info(MpegEncContext * s, AVRational aspect){
int i;
- aspect*= s->height/(double)s->width;
-//printf("%f\n", aspect);
-
- if(aspect==0) aspect= 1.0;
-
- ff_float2fraction(&s->aspected_width, &s->aspected_height, aspect, 255);
+ if(aspect.num==0) aspect= (AVRational){1,1};
-//printf("%d %d\n", s->aspected_width, s->aspected_height);
for(i=1; i<6; i++){
- if(s->aspected_width == pixel_aspect[i][0] && s->aspected_height== pixel_aspect[i][1]){
+ if(av_cmp_q(pixel_aspect[i], aspect) == 0){
s->aspect_ratio_info=i;
return;
}
if (format == 7) {
/* Custom Picture Format (CPFMT) */
- float_aspect_to_info(s, s->avctx->aspect_ratio);
+ aspect_to_info(s, s->avctx->sample_aspect_ratio);
put_bits(&s->pb,4,s->aspect_ratio_info);
put_bits(&s->pb,9,(s->width >> 2) - 1);
put_bits(&s->pb,1,1); /* "1" to prevent start code emulation */
put_bits(&s->pb,9,(s->height >> 2));
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
- {
- put_bits(&s->pb, 8, s->aspected_width);
- put_bits(&s->pb, 8, s->aspected_height);
+ if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
}
return 0;
}
-static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6])
+static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int block_last_index, uint8_t scantable[64]){
+ int last=0;
+ int j;
+ int rate=0;
+
+ for(j=1; j<=block_last_index; j++){
+ const int index= scantable[j];
+ int level= block[index];
+ if(level){
+ level+= 64;
+ if((level&(~127)) == 0){
+ if(j<block_last_index) rate+= s->intra_ac_vlc_length [UNI_AC_ENC_INDEX(j-last-1, level)];
+ else rate+= s->intra_ac_vlc_last_length[UNI_AC_ENC_INDEX(j-last-1, level)];
+ }else
+ rate += s->ac_esc_length;
+ level-= 64;
+
+ last= j;
+ }
+ }
+
+ return rate;
+}
+
+static inline int decide_ac_pred(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
{
- int score0=0, score1=0;
+ int score= 0;
int i, n;
int8_t * const qscale_table= s->current_picture.qscale_table;
+ memcpy(zigzag_last_index, s->block_last_index, sizeof(int)*6);
+
for(n=0; n<6; n++){
int16_t *ac_val, *ac_val1;
+
+ score -= get_block_rate(s, block[n], s->block_last_index[n], s->intra_scantable.permutated);
ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
ac_val1= ac_val;
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i ]];
- score0+= ABS(level);
- score1+= ABS(level - ac_val[i+8]);
+ block[n][s->dsp.idct_permutation[i ]] = level - ac_val[i+8];
ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i ]];
- score0+= ABS(level);
- score1+= ABS(level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale));
+ block[n][s->dsp.idct_permutation[i ]] = level - ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
ac_val1[i ]= block[n][s->dsp.idct_permutation[i<<3]];
ac_val1[i+8]= level;
}
}
+ st[n]= s->intra_h_scantable.permutated;
}else{
const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
/* left prediction */
/* same qscale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i<<3]];
- score0+= ABS(level);
- score1+= ABS(level - ac_val[i]);
+ block[n][s->dsp.idct_permutation[i<<3]]= level - ac_val[i];
ac_val1[i ]= level;
ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
/* different qscale, we must rescale */
for(i=1; i<8; i++){
const int level= block[n][s->dsp.idct_permutation[i<<3]];
- score0+= ABS(level);
- score1+= ABS(level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale));
+ block[n][s->dsp.idct_permutation[i<<3]]= level - ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
ac_val1[i ]= level;
ac_val1[i+8]= block[n][s->dsp.idct_permutation[i ]];
}
}
+ st[n]= s->intra_v_scantable.permutated;
}
+
+ for(i=63; i>0; i--) //FIXME optimize
+ if(block[n][ st[n][i] ]) break;
+ s->block_last_index[n]= i;
+
+ score += get_block_rate(s, block[n], s->block_last_index[n], st[n]);
}
- return score0 > score1 ? 1 : 0;
+ return score < 0;
+}
+
+static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], int dir[6], uint8_t *st[6], int zigzag_last_index[6])
+{
+ int i, n;
+ memcpy(s->block_last_index, zigzag_last_index, sizeof(int)*6);
+
+ for(n=0; n<6; n++){
+ int16_t *ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
+
+ st[n]= s->intra_scantable.permutated;
+ if(dir[n]){
+ /* top prediction */
+ for(i=1; i<8; i++){
+ block[n][s->dsp.idct_permutation[i ]] = ac_val[i+8];
+ }
+ }else{
+ /* left prediction */
+ for(i=1; i<8; i++){
+ block[n][s->dsp.idct_permutation[i<<3]]= ac_val[i ];
+ }
+ }
+ }
}
/**
}
#ifdef CONFIG_ENCODERS
+
+static inline int get_p_cbp(MpegEncContext * s,
+ DCTELEM block[6][64],
+ int motion_x, int motion_y){
+ int cbp, i;
+
+ if(s->flags & CODEC_FLAG_CBP_RD){
+ int best_cbpy_score= INT_MAX;
+ int best_cbpc_score= INT_MAX;
+ int cbpc, cbpy;
+ const int offset= (s->mv_type==MV_TYPE_16X16 ? 0 : 16) + (s->dquant ? 8 : 0);
+ const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+
+ for(i=0; i<4; i++){
+ int score= inter_MCBPC_bits[i + offset] * lambda;
+ if(i&1) score += s->coded_score[5];
+ if(i&2) score += s->coded_score[4];
+
+ if(score < best_cbpc_score){
+ best_cbpc_score= score;
+ cbpc= i;
+ }
+ }
+
+ for(i=0; i<16; i++){
+ int score= cbpy_tab[i ^ 0xF][1] * lambda;
+ if(i&1) score += s->coded_score[3];
+ if(i&2) score += s->coded_score[2];
+ if(i&4) score += s->coded_score[1];
+ if(i&8) score += s->coded_score[0];
+
+ if(score < best_cbpy_score){
+ best_cbpy_score= score;
+ cbpy= i;
+ }
+ }
+ cbp= cbpc + 4*cbpy;
+ if ((motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16){
+ if(best_cbpy_score + best_cbpc_score + 2*lambda >= 0)
+ cbp= 0;
+ }
+
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
+ s->block_last_index[i]= -1;
+ memset(s->block[i], 0, sizeof(DCTELEM)*64);
+ }
+ }
+ }else{
+ cbp= 0;
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ }
+ return cbp;
+}
+
+static inline int get_b_cbp(MpegEncContext * s, DCTELEM block[6][64],
+ int motion_x, int motion_y, int mb_type){
+ int cbp=0, i;
+
+ if(s->flags & CODEC_FLAG_CBP_RD){
+ int score=0;
+ const int lambda= s->lambda2 >> (FF_LAMBDA_SHIFT - 6);
+
+ for(i=0; i<6; i++){
+ if(s->coded_score[i] < 0){
+ score += s->coded_score[i];
+ cbp |= 1 << (5 - i);
+ }
+ }
+
+ if(cbp){
+ int zero_score= -6;
+ if ((motion_x | motion_y | s->dquant | mb_type) == 0){
+ zero_score-= 4; //2*MV + mb_type + cbp bit
+ }
+
+ zero_score*= lambda;
+ if(zero_score <= score){
+ cbp=0;
+ }
+ }
+
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0 && ((cbp >> (5 - i))&1)==0 ){
+ s->block_last_index[i]= -1;
+ memset(s->block[i], 0, sizeof(DCTELEM)*64);
+ }
+ }
+ }else{
+ for (i = 0; i < 6; i++) {
+ if (s->block_last_index[i] >= 0)
+ cbp |= 1 << (5 - i);
+ }
+ }
+ return cbp;
+}
+
void mpeg4_encode_mb(MpegEncContext * s,
DCTELEM block[6][64],
int motion_x, int motion_y)
// printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
- int i, cbp = 0;
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0)
- cbp |= 1 << (5 - i);
- }
-
+ int i, cbp;
+
if(s->pict_type==B_TYPE){
static const int mb_type_table[8]= {-1, 2, 3, 1,-1,-1,-1, 0}; /* convert from mv_dir to type */
int mb_type= mb_type_table[s->mv_dir];
return;
}
+ cbp= get_b_cbp(s, block, motion_x, motion_y, mb_type);
+
if ((cbp | motion_x | motion_y | mb_type) ==0) {
/* direct MB with MV={0,0} */
assert(s->dquant==0);
s->p_tex_bits+= get_bits_diff(s);
}
}else{ /* s->pict_type==B_TYPE */
+ cbp= get_p_cbp(s, block, motion_x, motion_y);
+
if ((cbp | motion_x | motion_y | s->dquant) == 0 && s->mv_type==MV_TYPE_16X16) {
/* check if the B frames can skip it too, as we must skip it if we skip here
why didnt they just compress the skip-mb bits instead of reusing them ?! */
}
}
- s->ac_pred= decide_ac_pred(s, block, dir);
-
- if(s->ac_pred){
- for(i=0; i<6; i++){
- uint8_t *st;
- int last_index;
-
- mpeg4_inv_pred_ac(s, block[i], i, dir[i]);
- if (dir[i]==0) st = s->intra_v_scantable.permutated; /* left */
- else st = s->intra_h_scantable.permutated; /* top */
-
- for(last_index=63; last_index>=0; last_index--) //FIXME optimize
- if(block[i][st[last_index]]) break;
- zigzag_last_index[i]= s->block_last_index[i];
- s->block_last_index[i]= last_index;
- scan_table[i]= st;
- }
+ if(s->flags & CODEC_FLAG_AC_PRED){
+ s->ac_pred= decide_ac_pred(s, block, dir, scan_table, zigzag_last_index);
+ if(!s->ac_pred)
+ restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
}else{
for(i=0; i<6; i++)
scan_table[i]= s->intra_scantable.permutated;
s->i_count++;
/* restore ac coeffs & last_index stuff if we messed them up with the prediction */
- if(s->ac_pred){
- for(i=0; i<6; i++){
- int j;
- int16_t *ac_val;
-
- ac_val = s->ac_val[0][0] + s->block_index[i] * 16;
-
- if(dir[i]){
- for(j=1; j<8; j++)
- block[i][s->dsp.idct_permutation[j ]]= ac_val[j+8];
- }else{
- for(j=1; j<8; j++)
- block[i][s->dsp.idct_permutation[j<<3]]= ac_val[j ];
- }
- s->block_last_index[i]= zigzag_last_index[i];
- }
- }
+ if(s->ac_pred)
+ restore_ac_coeffs(s, block, dir, scan_table, zigzag_last_index);
}
}
//printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
if (!s->mb_intra) {
/* compute cbp */
- cbp = 0;
- for (i = 0; i < 6; i++) {
- if (s->block_last_index[i] >= 0)
- cbp |= 1 << (5 - i);
- }
+ cbp= get_p_cbp(s, block, motion_x, motion_y);
+
if ((cbp | motion_x | motion_y | s->dquant) == 0) {
/* skip macroblock */
put_bits(&s->pb, 1, 1);
s->ac_esc_length= 7+2+1+6+1+12+1;
if(s->flags & CODEC_FLAG_GLOBAL_HEADER){
+
s->avctx->extradata= av_malloc(1024);
- init_put_bits(&s->pb, s->avctx->extradata, 1024, NULL, NULL);
+ init_put_bits(&s->pb, s->avctx->extradata, 1024);
mpeg4_encode_visual_object_header(s);
mpeg4_encode_vol_header(s, 0, 0);
put_bits(&s->pb, 4, vo_ver_id); /* is obj layer ver id */
put_bits(&s->pb, 3, 1); /* is obj layer priority */
- float_aspect_to_info(s, s->avctx->aspect_ratio);
+ aspect_to_info(s, s->avctx->sample_aspect_ratio);
put_bits(&s->pb, 4, s->aspect_ratio_info);/* aspect ratio info */
- if (s->aspect_ratio_info == FF_ASPECT_EXTENDED)
- {
- put_bits(&s->pb, 8, s->aspected_width);
- put_bits(&s->pb, 8, s->aspected_height);
+ if (s->aspect_ratio_info == FF_ASPECT_EXTENDED){
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.num);
+ put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
}
if(s->low_delay){
#ifdef CONFIG_ENCODERS
-static void mpeg4_inv_pred_ac(MpegEncContext * s, DCTELEM *block, int n,
- int dir)
-{
- int i;
- int16_t *ac_val;
- int8_t * const qscale_table= s->current_picture.qscale_table;
-
- /* find prediction */
- ac_val = s->ac_val[0][0] + s->block_index[n] * 16;
-
- if (dir == 0) {
- const int xy= s->mb_x-1 + s->mb_y*s->mb_stride;
- /* left prediction */
- ac_val -= 16;
- if(s->mb_x==0 || s->qscale == qscale_table[xy] || n==1 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] -= ac_val[i];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i<<3]] -= ROUNDED_DIV(ac_val[i]*qscale_table[xy], s->qscale);
- }
- }
- } else {
- const int xy= s->mb_x + s->mb_y*s->mb_stride - s->mb_stride;
- /* top prediction */
- ac_val -= 16 * s->block_wrap[n];
- if(s->mb_y==0 || s->qscale == qscale_table[xy] || n==2 || n==3){
- /* same qscale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] -= ac_val[i + 8];
- }
- }else{
- /* different qscale, we must rescale */
- for(i=1;i<8;i++) {
- block[s->dsp.idct_permutation[i]] -= ROUNDED_DIV(ac_val[i + 8]*qscale_table[xy], s->qscale);
- }
- }
- }
-}
-
/**
* encodes the dc value.
* @param n block index (0-3 are luma, 4-5 are chroma)
void ff_mpeg4_init_partitions(MpegEncContext *s)
{
- init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE, NULL, NULL);
- init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE, NULL, NULL);
+ init_put_bits(&s->tex_pb, s->tex_pb_buffer, PB_BUFFER_SIZE);
+ init_put_bits(&s->pb2 , s->pb2_buffer , PB_BUFFER_SIZE);
}
void ff_mpeg4_merge_partitions(MpegEncContext *s)
int ff_h263_resync(MpegEncContext *s){
int left, ret;
- if(s->codec_id==CODEC_ID_MPEG4)
+ if(s->codec_id==CODEC_ID_MPEG4){
skip_bits1(&s->gb);
-
- align_get_bits(&s->gb);
+ align_get_bits(&s->gb);
+ }
if(show_bits(&s->gb, 16)==0){
if(s->codec_id==CODEC_ID_MPEG4)
int16_t * const mot_val= s->motion_val[s->block_index[0]];
const int stride= s->block_wrap[0]*2;
- do{
+// do{ //FIXME
bits= show_bits(&s->gb, 17);
if(bits==MOTION_MARKER){
return mb_num-1;
fprintf(stderr, "cbpc corrupted at %d %d\n", s->mb_x, s->mb_y);
return -1;
}
- }while(cbpc == 20);
+// }while(cbpc == 20);
s->cbp_table[xy]= cbpc&(8+3); //8 is dquant
int16_t *mot_val;
static int8_t quant_tab[4] = { -1, -2, 1, 2 };
const int xy= s->mb_x + s->mb_y * s->mb_stride;
-
+
if (s->pict_type == P_TYPE || s->pict_type==S_TYPE) {
do{
if (get_bits1(&s->gb)) {
//Note intra & rvlc should be optimized away if this is inlined
if(intra) {
+ if(s->qscale < s->intra_dc_threshold){
/* DC coef */
if(s->partitioned_frame){
level = s->dc_val[0][ s->block_index[n] ];
}
block[0] = level;
i = 0;
+ }else{
+ i = -1;
+ }
if (!coded)
goto not_coded;
fprintf(stderr, "|level| overflow in 3. esc, qp=%d\n", s->qscale);
return -1;
}
-#if 1
- {
+#if 0
+ if(s->error_resilience >= FF_ER_COMPLIANT){
const int abs_level= ABS(level);
- if(abs_level<=MAX_LEVEL && run<=MAX_RUN && !(s->workaround_bugs&FF_BUG_AC_VLC)){
+ if(abs_level<=MAX_LEVEL && run<=MAX_RUN){
const int run1= run - rl->max_run[last][abs_level] - 1;
if(abs_level <= rl->max_level[last][run]){
fprintf(stderr, "illegal 3. esc, vlc encoding possible\n");
CLOSE_READER(re, &s->gb);
}
not_coded:
- if (s->mb_intra) {
+ if (intra) {
+ if(s->qscale >= s->intra_dc_threshold){
+ uint16_t *dc_val;
+ block[0] += ff_mpeg4_pred_dc(s, n, &dc_val, &dc_pred_dir);
+ if (n < 4) {
+ *dc_val = block[0] * s->y_dc_scale;
+ } else {
+ *dc_val = block[0] * s->c_dc_scale;
+ }
+
+ if(i == -1) i=0;
+ }
+
mpeg4_pred_ac(s, block, n, dc_pred_dir);
if (s->ac_pred) {
i = 63; /* XXX: not optimal */
dprintf("ufep=1, format: %d\n", format);
skip_bits(&s->gb,1); /* Custom PCF */
s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
+ s->unrestricted_mv = s->umvplus;
skip_bits1(&s->gb); /* Syntax-based Arithmetic Coding (SAC) */
if (get_bits1(&s->gb) != 0) {
s->mv_type = MV_TYPE_8X8; /* Advanced prediction mode */
dprintf("\nH.263+ Custom picture: %dx%d\n",width,height);
if (s->aspect_ratio_info == FF_ASPECT_EXTENDED) {
/* aspected dimensions */
- s->aspected_width = get_bits(&s->gb, 8);
- s->aspected_height = get_bits(&s->gb, 8);
+ s->avctx->sample_aspect_ratio.num= get_bits(&s->gb, 8);
+ s->avctx->sample_aspect_ratio.den= get_bits(&s->gb, 8);
}else{
- s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
- s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
+ s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
} else {
width = h263_format[format][0];
//printf("vo type:%d\n",s->vo_type);
s->aspect_ratio_info= get_bits(gb, 4);
if(s->aspect_ratio_info == FF_ASPECT_EXTENDED){
- s->aspected_width = get_bits(gb, 8); // par_width
- s->aspected_height = get_bits(gb, 8); // par_height
+ s->avctx->sample_aspect_ratio.num= get_bits(gb, 8); // par_width
+ s->avctx->sample_aspect_ratio.den= get_bits(gb, 8); // par_height
}else{
- s->aspected_width = pixel_aspect[s->aspect_ratio_info][0];
- s->aspected_height= pixel_aspect[s->aspect_ratio_info][1];
+ s->avctx->sample_aspect_ratio= pixel_aspect[s->aspect_ratio_info];
}
if ((s->vol_control_parameters=get_bits1(gb))) { /* vol control parameter */
//FIXME complexity estimation stuff
if (s->shape != BIN_ONLY_SHAPE) {
- int t;
- t=get_bits(gb, 3); /* intra dc VLC threshold */
-//printf("threshold %d\n", t);
+ s->intra_dc_threshold= mpeg4_dc_threshold[ get_bits(gb, 3) ];
if(!s->progressive_sequence){
s->top_field_first= get_bits1(gb);
s->alternate_scan= get_bits1(gb);
s->b_code=1;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- printf("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s\n",
+ printf("qp:%d fc:%d,%d %s size:%d pro:%d alt:%d top:%d %spel part:%d resync:%d w:%d a:%d rnd:%d vot:%d%s dc:%d\n",
s->qscale, s->f_code, s->b_code,
s->pict_type == I_TYPE ? "I" : (s->pict_type == P_TYPE ? "P" : (s->pict_type == B_TYPE ? "B" : "S")),
gb->size_in_bits,s->progressive_sequence, s->alternate_scan, s->top_field_first,
s->quarter_sample ? "q" : "h", s->data_partitioning, s->resync_marker, s->num_sprite_warping_points,
- s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ");
+ s->sprite_warping_accuracy, 1-s->no_rounding, s->vo_type, s->vol_control_parameters ? " VOLC" : " ", s->intra_dc_threshold);
}
if(!s->scalability){
printf(" at %d\n", get_bits_count(gb));
}
- switch(startcode){
- case 0x120:
+ if(startcode >= 0x120 && startcode <= 0x12F){
if(decode_vol_header(s, gb) < 0)
return -1;
- break;
- case USER_DATA_STARTCODE:
+ }
+ else if(startcode == USER_DATA_STARTCODE){
decode_user_data(s, gb);
- break;
- case GOP_STARTCODE:
+ }
+ else if(startcode == GOP_STARTCODE){
mpeg4_decode_gop_header(s, gb);
- break;
- case VOP_STARTCODE:
+ }
+ else if(startcode == VOP_STARTCODE){
return decode_vop_header(s, gb);
- default:
- break;
}
align_get_bits(gb);