]> git.sesse.net Git - ffmpeg/blobdiff - libavcodec/mpegvideo.h
Fix overflows in bicubic interpolation.
[ffmpeg] / libavcodec / mpegvideo.h
index da9f0ba3fbab68c23ed8ef7e5797771c303bc2ff..023e657004458fb3c979dd5054de9dcfecb44033 100644 (file)
@@ -15,7 +15,7 @@
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 /**
@@ -70,6 +70,8 @@ enum OutputFormat {
 
 #define MAX_MB_BYTES (30*16*16*3/8 + 120)
 
+#define INPLACE_OFFSET 16
+
 typedef struct Predictor{
     double coeff;
     double count;
@@ -83,12 +85,14 @@ typedef struct RateControlEntry{
     int i_tex_bits;
     int p_tex_bits;
     int misc_bits;
+    int header_bits;
     uint64_t expected_bits;
     int new_pict_type;
     float new_qscale;
     int mc_mb_var_sum;
     int mb_var_sum;
     int i_count;
+    int skip_count;
     int f_code;
     int b_code;
 }RateControlEntry;
@@ -116,6 +120,10 @@ typedef struct RateControlContext{
     uint64_t qscale_sum[5];
     int frame_count[5];
     int last_non_b_pict_type;
+
+    void *non_lavc_opaque;        ///< context for non lavc rc code (for example xvid)
+    float dry_run_qscale;         ///< for xvid rc
+    int last_picture_number;      ///< for xvid rc
 }RateControlContext;
 
 /**
@@ -126,8 +134,8 @@ typedef struct ScanTable{
     uint8_t permutated[64];
     uint8_t raster_end[64];
 #ifdef ARCH_POWERPC
-               /** Used by dct_quantise_alitvec to find last-non-zero */
-    uint8_t __align8 inverse[64];
+                /** Used by dct_quantise_alitvec to find last-non-zero */
+    DECLARE_ALIGNED_8(uint8_t, inverse[64]);
 #endif
 } ScanTable;
 
@@ -181,7 +189,7 @@ typedef struct Picture{
     uint16_t *mb_var;           ///< Table for MB variances
     uint16_t *mc_mb_var;        ///< Table for motion compensated MB variances
     uint8_t *mb_mean;           ///< Table for MB luminance
-    int32_t *mb_cmp_score;     ///< Table for MB cmp scores, for mb decision FIXME remove
+    int32_t *mb_cmp_score;      ///< Table for MB cmp scores, for mb decision FIXME remove
     int b_frame_score;          /* */
 } Picture;
 
@@ -189,7 +197,7 @@ typedef struct ParseContext{
     uint8_t *buffer;
     int index;
     int last_index;
-    int buffer_size;
+    unsigned int buffer_size;
     uint32_t state;             ///< contains the last few bytes in MSB order
     int frame_start_found;
     int overread;               ///< the number of bytes which where irreversibly read from the next frame
@@ -245,7 +253,7 @@ typedef struct MotionEstContext{
     uint8_t (*mv_penalty)[MAX_MV*2+1];  ///< amount of bits needed to encode a MV
     uint8_t *current_mv_penalty;
     int (*sub_motion_search)(struct MpegEncContext * s,
-                                 int *mx_ptr, int *my_ptr, int dmin,
+                                  int *mx_ptr, int *my_ptr, int dmin,
                                   int src_index, int ref_index,
                                   int size, int h);
 }MotionEstContext;
@@ -374,6 +382,7 @@ typedef struct MpegEncContext {
     int last_non_b_pict_type;   ///< used for mpeg4 gmc b-frames & ratecontrol
     int dropable;
     int frame_rate_index;
+    int last_lambda_for[5];     ///< last lambda for a specific pict type
 
     /* motion compensation */
     int unrestricted_mv;        ///< mv can point outside of the coded picture
@@ -421,6 +430,7 @@ typedef struct MpegEncContext {
     int field_select[2][2];
     int last_mv[2][2][2];             ///< last MV, used for MV prediction in MPEG1 & B-frame MPEG4
     uint8_t *fcode_tab;               ///< smallest fcode needed for each MV
+    int16_t direct_scale_mv[2][64];   ///< precomputed to avoid divisions in ff_mpeg4_set_direct_mv
 
     MotionEstContext me;
 
@@ -476,7 +486,7 @@ typedef struct MpegEncContext {
     uint8_t *chroma_dc_vlc_length;
 #define UNI_AC_ENC_INDEX(run,level) ((run)*128 + (level))
 
-    int coded_score[6];
+    int coded_score[8];
 
     /** precomputed matrix (combine qscale and DCT renorm) */
     int (*q_intra_matrix)[64];
@@ -486,7 +496,7 @@ typedef struct MpegEncContext {
     uint16_t (*q_inter_matrix16)[2][64];
     int block_last_index[12];  ///< last non zero coefficient in block
     /* scantables */
-    ScanTable __align8 intra_scantable;
+    DECLARE_ALIGNED_8(ScanTable, intra_scantable);
     ScanTable intra_h_scantable;
     ScanTable intra_v_scantable;
     ScanTable inter_scantable; ///< if inter == intra then intra should be used to reduce tha cache usage
@@ -592,6 +602,7 @@ typedef struct MpegEncContext {
     int vo_type;
     int vol_control_parameters;      ///< does the stream contain the low_delay flag, used to workaround buggy encoders
     int intra_dc_threshold;          ///< QP above whch the ac VLC should be used for intra dc
+    int use_intra_dc_vlc;
     PutBitContext tex_pb;            ///< used for data partitioned VOPs
     PutBitContext pb2;               ///< used for data partitioned VOPs
     int mpeg_quant;
@@ -604,7 +615,7 @@ typedef struct MpegEncContext {
     int divx_packed;
     uint8_t *bitstream_buffer; //Divx 5.01 puts several frames in a single one, this is used to reorder them
     int bitstream_buffer_size;
-    int allocated_bitstream_buffer_size;
+    unsigned int allocated_bitstream_buffer_size;
 
     int xvid_build;
 
@@ -688,7 +699,7 @@ typedef struct MpegEncContext {
     short * pblocks[12];
 
     DCTELEM (*block)[64]; ///< points to one of the following blocks
-    DCTELEM (*blocks)[6][64]; // for HQ mode we need to keep the best block
+    DCTELEM (*blocks)[8][64]; // for HQ mode we need to keep the best block
     int (*decode_mb)(struct MpegEncContext *s, DCTELEM block[6][64]); // used by some codecs to avoid a switch()
 #define SLICE_OK         0
 #define SLICE_ERROR     -1
@@ -765,6 +776,7 @@ void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix);
 int ff_find_unused_picture(MpegEncContext *s, int shared);
 void ff_denoise_dct(MpegEncContext *s, DCTELEM *block);
 void ff_update_duplicate_context(MpegEncContext *dst, MpegEncContext *src);
+const uint8_t *ff_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);
 
 void ff_er_frame_start(MpegEncContext *s);
 void ff_er_frame_end(MpegEncContext *s);
@@ -972,7 +984,7 @@ void ff_mjpeg_stuffing(PutBitContext * pbc);
 
 /* rate control */
 int ff_rate_control_init(MpegEncContext *s);
-float ff_rate_estimate_qscale(MpegEncContext *s);
+float ff_rate_estimate_qscale(MpegEncContext *s, int dry_run);
 void ff_write_pass1_stats(MpegEncContext *s);
 void ff_rate_control_uninit(MpegEncContext *s);
 double ff_eval(char *s, double *const_value, const char **const_name,
@@ -980,6 +992,10 @@ double ff_eval(char *s, double *const_value, const char **const_name,
                double (**func2)(void *, double, double), char **func2_name,
                void *opaque);
 int ff_vbv_update(MpegEncContext *s, int frame_size);
+void ff_get_2pass_fcode(MpegEncContext *s);
 
+int ff_xvid_rate_control_init(MpegEncContext *s);
+void ff_xvid_rate_control_uninit(MpegEncContext *s);
+float ff_xvid_rate_estimate_qscale(MpegEncContext *s, int dry_run);
 
 #endif /* AVCODEC_MPEGVIDEO_H */