]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpeg4videoenc.c
qpeg: use reget_buffer() in decode_frame()
[ffmpeg] / libavcodec / mpeg4videoenc.c
index 36dd3c90a2f5737ced3645a0542cc34666aec2c2..33ecc0ae464108c3ab0b4a3c88a2dac07b084bb2 100644 (file)
@@ -3,20 +3,20 @@
  * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2010 Michael Niedermayer <michaelni@gmx.at>
  *
- * This file is part of FFmpeg.
+ * This file is part of Libav.
  *
- * FFmpeg is free software; you can redistribute it and/or
+ * Libav is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or (at your option) any later version.
  *
- * FFmpeg is distributed in the hope that it will be useful,
+ * Libav is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with FFmpeg; if not, write to the Free Software
+ * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
@@ -54,7 +54,7 @@ max run: 29/41
 
 
 /**
- * Returns the number of bits that encoding the 8x8 block in block would need.
+ * Return the number of bits that encoding the 8x8 block in block would need.
  * @param[in]  block_last_index last index in scantable order that refers to a non zero element in block.
  */
 static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int block_last_index, uint8_t scantable[64]){
@@ -82,7 +82,7 @@ static inline int get_block_rate(MpegEncContext * s, DCTELEM block[64], int bloc
 
 
 /**
- * Restores the ac coefficients in block that have been changed by decide_ac_pred().
+ * Restore the ac coefficients in block that have been changed by decide_ac_pred().
  * This function also restores s->block_last_index.
  * @param[in,out] block MB coefficients, these will be restored
  * @param[in] dir ac prediction direction for each 8x8 block
@@ -113,7 +113,7 @@ static inline void restore_ac_coeffs(MpegEncContext * s, DCTELEM block[6][64], c
 }
 
 /**
- * Returns the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.
+ * Return the optimal value (0 or 1) for the ac_pred element for the given MB in mpeg4.
  * This function will also update s->block_last_index and s->ac_val.
  * @param[in,out] block MB coefficients, these will be updated if 1 is returned
  * @param[in] dir ac prediction direction for each 8x8 block
@@ -263,10 +263,10 @@ static inline void mpeg4_encode_dc(PutBitContext * s, int level, int n)
 
     if (n < 4) {
         /* luminance */
-        put_bits(&s->pb, DCtab_lum[size][1], DCtab_lum[size][0]);
+        put_bits(&s->pb, ff_mpeg4_DCtab_lum[size][1], ff_mpeg4_DCtab_lum[size][0]);
     } else {
         /* chrominance */
-        put_bits(&s->pb, DCtab_chrom[size][1], DCtab_chrom[size][0]);
+        put_bits(&s->pb, ff_mpeg4_DCtab_chrom[size][1], ff_mpeg4_DCtab_chrom[size][0]);
     }
 
     /* encode remaining bits */
@@ -309,13 +309,13 @@ static inline void mpeg4_encode_block(MpegEncContext * s, DCTELEM * block, int n
         mpeg4_encode_dc(dc_pb, intra_dc, n);
         if(last_index<1) return;
         i = 1;
-        rl = &rl_intra;
+        rl = &ff_mpeg4_rl_intra;
         bits_tab= uni_mpeg4_intra_rl_bits;
         len_tab = uni_mpeg4_intra_rl_len;
     } else {
         if(last_index<0) return;
         i = 0;
-        rl = &rl_inter;
+        rl = &ff_h263_rl_inter;
         bits_tab= uni_mpeg4_inter_rl_bits;
         len_tab = uni_mpeg4_inter_rl_len;
     }
@@ -697,10 +697,10 @@ void mpeg4_encode_mb(MpegEncContext * s,
             if(s->mv_type==MV_TYPE_16X16){
                 if(s->dquant) cbpc+= 8;
                 put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc],
-                        inter_MCBPC_code[cbpc]);
+                        ff_h263_inter_MCBPC_bits[cbpc],
+                        ff_h263_inter_MCBPC_code[cbpc]);
 
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
+                put_bits(pb2, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
                 if(s->dquant)
                     put_bits(pb2, 2, dquant_code[s->dquant+2]);
 
@@ -722,10 +722,10 @@ void mpeg4_encode_mb(MpegEncContext * s,
             }else if(s->mv_type==MV_TYPE_FIELD){
                 if(s->dquant) cbpc+= 8;
                 put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc],
-                        inter_MCBPC_code[cbpc]);
+                        ff_h263_inter_MCBPC_bits[cbpc],
+                        ff_h263_inter_MCBPC_code[cbpc]);
 
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
+                put_bits(pb2, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
                 if(s->dquant)
                     put_bits(pb2, 2, dquant_code[s->dquant+2]);
 
@@ -752,9 +752,9 @@ void mpeg4_encode_mb(MpegEncContext * s,
             }else{
                 assert(s->mv_type==MV_TYPE_8X8);
                 put_bits(&s->pb,
-                        inter_MCBPC_bits[cbpc+16],
-                        inter_MCBPC_code[cbpc+16]);
-                put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
+                        ff_h263_inter_MCBPC_bits[cbpc+16],
+                        ff_h263_inter_MCBPC_code[cbpc+16]);
+                put_bits(pb2, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
 
                 if(!s->progressive_sequence){
                     if(cbp)
@@ -815,18 +815,18 @@ void mpeg4_encode_mb(MpegEncContext * s,
         if (s->pict_type == FF_I_TYPE) {
             if(s->dquant) cbpc+=4;
             put_bits(&s->pb,
-                intra_MCBPC_bits[cbpc],
-                intra_MCBPC_code[cbpc]);
+                ff_h263_intra_MCBPC_bits[cbpc],
+                ff_h263_intra_MCBPC_code[cbpc]);
         } else {
             if(s->dquant) cbpc+=8;
             put_bits(&s->pb, 1, 0);     /* mb coded */
             put_bits(&s->pb,
-                inter_MCBPC_bits[cbpc + 4],
-                inter_MCBPC_code[cbpc + 4]);
+                ff_h263_inter_MCBPC_bits[cbpc + 4],
+                ff_h263_inter_MCBPC_code[cbpc + 4]);
         }
         put_bits(pb2, 1, s->ac_pred);
         cbpy = cbp >> 2;
-        put_bits(pb2, cbpy_tab[cbpy][1], cbpy_tab[cbpy][0]);
+        put_bits(pb2, ff_h263_cbpy_tab[cbpy][1], ff_h263_cbpy_tab[cbpy][0]);
         if(s->dquant)
             put_bits(dc_pb, 2, dquant_code[s->dquant+2]);
 
@@ -1125,8 +1125,8 @@ static void init_uni_dc_tab(void)
             l= level;
 
         /* luminance */
-        uni_code= DCtab_lum[size][0];
-        uni_len = DCtab_lum[size][1];
+        uni_code= ff_mpeg4_DCtab_lum[size][0];
+        uni_len = ff_mpeg4_DCtab_lum[size][1];
 
         if (size > 0) {
             uni_code<<=size; uni_code|=l;
@@ -1140,8 +1140,8 @@ static void init_uni_dc_tab(void)
         uni_DCtab_lum_len [level+256]= uni_len;
 
         /* chrominance */
-        uni_code= DCtab_chrom[size][0];
-        uni_len = DCtab_chrom[size][1];
+        uni_code= ff_mpeg4_DCtab_chrom[size][0];
+        uni_len = ff_mpeg4_DCtab_chrom[size][1];
 
         if (size > 0) {
             uni_code<<=size; uni_code|=l;
@@ -1252,10 +1252,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
 
         init_uni_dc_tab();
 
-        init_rl(&rl_intra, ff_mpeg4_static_rl_table_store[0]);
+        init_rl(&ff_mpeg4_rl_intra, ff_mpeg4_static_rl_table_store[0]);
 
-        init_uni_mpeg4_rl_tab(&rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
-        init_uni_mpeg4_rl_tab(&rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
+        init_uni_mpeg4_rl_tab(&ff_mpeg4_rl_intra, uni_mpeg4_intra_rl_bits, uni_mpeg4_intra_rl_len);
+        init_uni_mpeg4_rl_tab(&ff_h263_rl_inter, uni_mpeg4_inter_rl_bits, uni_mpeg4_inter_rl_len);
     }
 
     s->min_qcoeff= -2048;
@@ -1338,15 +1338,15 @@ void ff_mpeg4_encode_video_packet_header(MpegEncContext *s)
     put_bits(&s->pb, 1, 0); /* no HEC */
 }
 
-AVCodec mpeg4_encoder = {
+AVCodec ff_mpeg4_encoder = {
     "mpeg4",
-    CODEC_TYPE_VIDEO,
+    AVMEDIA_TYPE_VIDEO,
     CODEC_ID_MPEG4,
     sizeof(MpegEncContext),
     encode_init,
     MPV_encode_picture,
     MPV_encode_end,
     .pix_fmts= (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
-    .capabilities= CODEC_CAP_DELAY,
+    .capabilities= CODEC_CAP_DELAY | CODEC_CAP_SLICE_THREADS,
     .long_name= NULL_IF_CONFIG_SMALL("MPEG-4 part 2"),
 };