* Copyright (c) 2001 Juan J. Sierralta P.
* Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
*
+ * ac prediction encoding, B-frame support, error resilience, optimizations,
+ * qpel decoding, gmc decoding, interlaced decoding
+ * by Michael Niedermayer <michaelni@gmx.at>
+ *
* This file is part of FFmpeg.
*
* FFmpeg is free software; you can redistribute it and/or
* You should have received a copy of the GNU Lesser General Public
* License along with FFmpeg; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * ac prediction encoding, b-frame support, error resilience, optimizations,
- * qpel decoding, gmc decoding, interlaced decoding,
- * by Michael Niedermayer <michaelni@gmx.at>
*/
/**
return format;
}
+static void show_pict_info(MpegEncContext *s){
+ av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
+ s->qscale, av_get_pict_type_char(s->pict_type),
+ s->gb.size_in_bits, 1-s->no_rounding,
+ s->obmc ? " AP" : "",
+ s->umvplus ? " UMV" : "",
+ s->h263_long_vectors ? " LONG" : "",
+ s->h263_plus ? " +" : "",
+ s->h263_aic ? " AIC" : "",
+ s->alt_inter_vlc ? " AIV" : "",
+ s->modified_quant ? " MQ" : "",
+ s->loop_filter ? " LOOP" : "",
+ s->h263_slice_structured ? " SS" : "",
+ s->avctx->time_base.den, s->avctx->time_base.num
+ );
+}
+
#ifdef CONFIG_ENCODERS
static void aspect_to_info(MpegEncContext * s, AVRational aspect){
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 */
+ static const int mb_type_table[8]= {-1, 3, 2, 1,-1,-1,-1, 0}; /* convert from mv_dir to type */
int mb_type= mb_type_table[s->mv_dir];
if(s->mb_x==0){
umv_fcode_tab[mv]= 1;
}
}
-#endif
-
-#ifdef CONFIG_ENCODERS
static void init_uni_dc_tab(void)
{
}
}
-#endif //CONFIG_ENCODERS
-
-#ifdef CONFIG_ENCODERS
static void init_uni_mpeg4_rl_tab(RLTable *rl, uint32_t *bits_tab, uint8_t *len_tab){
int slevel, run, last;
}
}
}
-#endif
-
-#ifdef CONFIG_ENCODERS
/***************************************************/
/**
}
/* must be called before writing the header */
-void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
- int time_div, time_mod;
-
- assert(s->current_picture_ptr->pts != AV_NOPTS_VALUE);
- s->time= s->current_picture_ptr->pts*s->avctx->time_base.num;
-
- time_div= s->time/s->avctx->time_base.den;
- time_mod= s->time%s->avctx->time_base.den;
-
+void ff_set_mpeg4_time(MpegEncContext * s){
if(s->pict_type==B_TYPE){
- s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
- assert(s->pb_time > 0 && s->pb_time < s->pp_time);
ff_mpeg4_init_direct_mv(s);
}else{
s->last_time_base= s->time_base;
- s->time_base= time_div;
- s->pp_time= s->time - s->last_non_b_time;
- s->last_non_b_time= s->time;
- assert(picture_number==0 || s->pp_time > 0);
+ s->time_base= s->time/s->avctx->time_base.den;
}
}
{
int vo_ver_id;
+ if (!ENABLE_MPEG4_ENCODER) return;
+
if(s->max_b_frames || s->quarter_sample){
vo_ver_id= 5;
s->vo_type= ADV_SIMPLE_VO_TYPE;
#endif //CONFIG_ENCODERS
-/**
- * set qscale and update qscale dependent variables.
- */
-void ff_set_qscale(MpegEncContext * s, int qscale)
-{
- if (qscale < 1)
- qscale = 1;
- else if (qscale > 31)
- qscale = 31;
-
- s->qscale = qscale;
- s->chroma_qscale= s->chroma_qscale_table[qscale];
-
- s->y_dc_scale= s->y_dc_scale_table[ qscale ];
- s->c_dc_scale= s->c_dc_scale_table[ s->chroma_qscale ];
-}
-
/**
* predicts the dc.
* encoding quantized level -> quantized diff
static VLC h263_mbtype_b_vlc;
static VLC cbpc_b_vlc;
-void init_vlc_rl(RLTable *rl, int use_static)
-{
- int i, q;
-
- /* Return if static table is already initialized */
- if(use_static && rl->rl_vlc[0])
- return;
-
- init_vlc(&rl->vlc, 9, rl->n + 1,
- &rl->table_vlc[0][1], 4, 2,
- &rl->table_vlc[0][0], 4, 2, use_static);
-
-
- for(q=0; q<32; q++){
- int qmul= q*2;
- int qadd= (q-1)|1;
-
- if(q==0){
- qmul=1;
- qadd=0;
- }
- if(use_static)
- rl->rl_vlc[q]= av_mallocz_static(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
- else
- rl->rl_vlc[q]= av_malloc(rl->vlc.table_size*sizeof(RL_VLC_ELEM));
- for(i=0; i<rl->vlc.table_size; i++){
- int code= rl->vlc.table[i][0];
- int len = rl->vlc.table[i][1];
- int level, run;
-
- if(len==0){ // illegal code
- run= 66;
- level= MAX_LEVEL;
- }else if(len<0){ //more bits needed
- run= 0;
- level= code;
- }else{
- if(code==rl->n){ //esc
- run= 66;
- level= 0;
- }else{
- run= rl->table_run [code] + 1;
- level= rl->table_level[code] * qmul + qadd;
- if(code >= rl->last) run+=192;
- }
- }
- rl->rl_vlc[q][i].len= len;
- rl->rl_vlc[q][i].level= level;
- rl->rl_vlc[q][i].run= run;
- }
- }
-}
-
/* init vlcs */
/* XXX: find a better solution to handle static init */
format = get_bits(&s->gb, 3);
dprintf(s->avctx, "ufep=1, format: %d\n", format);
s->custom_pcf= get_bits1(&s->gb);
- s->umvplus = get_bits(&s->gb, 1); /* Unrestricted Motion Vector */
+ s->umvplus = get_bits1(&s->gb); /* Unrestricted Motion Vector */
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "Syntax-based Arithmetic Coding (SAC) not supported\n");
}
}
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(s->avctx, AV_LOG_DEBUG, "qp:%d %c size:%d rnd:%d%s%s%s%s%s%s%s%s%s %d/%d\n",
- s->qscale, av_get_pict_type_char(s->pict_type),
- s->gb.size_in_bits, 1-s->no_rounding,
- s->obmc ? " AP" : "",
- s->umvplus ? " UMV" : "",
- s->h263_long_vectors ? " LONG" : "",
- s->h263_plus ? " +" : "",
- s->h263_aic ? " AIC" : "",
- s->alt_inter_vlc ? " AIV" : "",
- s->modified_quant ? " MQ" : "",
- s->loop_filter ? " LOOP" : "",
- s->h263_slice_structured ? " SS" : "",
- s->avctx->time_base.den, s->avctx->time_base.num
- );
+ show_pict_info(s);
}
#if 1
if (s->pict_type == I_TYPE && s->codec_tag == ff_get_fourcc("ZYGO")){
av_log(s->avctx, AV_LOG_ERROR, "SAC not supported\n");
return -1; /* SAC: off */
}
- if (get_bits1(&s->gb) != 0) {
- s->obmc= 1;
- av_log(s->avctx, AV_LOG_ERROR, "Advanced Prediction Mode not supported\n");
-// return -1; /* advanced prediction mode: off */
- }
+ s->obmc= get_bits1(&s->gb);
if (get_bits1(&s->gb) != 0) {
av_log(s->avctx, AV_LOG_ERROR, "PB frame mode no supported\n");
return -1; /* PB frame mode */
s->y_dc_scale_table=
s->c_dc_scale_table= ff_mpeg1_dc_scale_table;
+ if(s->avctx->debug&FF_DEBUG_PICT_INFO)
+ show_pict_info(s);
+
return 0;
}