summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libffmpeg/audio_decoder.c5
-rw-r--r--src/libffmpeg/libavcodec/adpcm.c10
-rw-r--r--src/libffmpeg/libavcodec/alac.c12
-rw-r--r--src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c3
-rw-r--r--src/libffmpeg/libavcodec/avcodec.h373
-rw-r--r--src/libffmpeg/libavcodec/avs.c4
-rw-r--r--src/libffmpeg/libavcodec/bytestream.h4
-rw-r--r--src/libffmpeg/libavcodec/cabac.h22
-rw-r--r--src/libffmpeg/libavcodec/cinepak.c20
-rw-r--r--src/libffmpeg/libavcodec/cook.c114
-rw-r--r--src/libffmpeg/libavcodec/dpcm.c10
-rw-r--r--src/libffmpeg/libavcodec/dv.c9
-rw-r--r--src/libffmpeg/libavcodec/dvdata.h6
-rw-r--r--src/libffmpeg/libavcodec/eval.c2
-rw-r--r--src/libffmpeg/libavcodec/flac.c14
-rw-r--r--src/libffmpeg/libavcodec/flashsv.c20
-rw-r--r--src/libffmpeg/libavcodec/flicvideo.c48
-rw-r--r--src/libffmpeg/libavcodec/fraps.c8
-rw-r--r--src/libffmpeg/libavcodec/h263.c4
-rw-r--r--src/libffmpeg/libavcodec/h263dec.c2
-rw-r--r--src/libffmpeg/libavcodec/h264.c256
-rw-r--r--src/libffmpeg/libavcodec/i386/idct_mmx.c2
-rw-r--r--src/libffmpeg/libavcodec/imgconvert.c51
-rw-r--r--src/libffmpeg/libavcodec/imgresample.c2
-rw-r--r--src/libffmpeg/libavcodec/kmvc.c4
-rw-r--r--src/libffmpeg/libavcodec/loco.c8
-rw-r--r--src/libffmpeg/libavcodec/lzo.c74
-rw-r--r--src/libffmpeg/libavcodec/lzo.h4
-rw-r--r--src/libffmpeg/libavcodec/mjpeg.c4
-rw-r--r--src/libffmpeg/libavcodec/mmvideo.c4
-rw-r--r--src/libffmpeg/libavcodec/mpeg12.c4
-rw-r--r--src/libffmpeg/libavcodec/mpegvideo.c40
-rw-r--r--src/libffmpeg/libavcodec/msvideo1.c16
-rw-r--r--src/libffmpeg/libavcodec/nuv.c4
-rw-r--r--src/libffmpeg/libavcodec/opt.c48
-rw-r--r--src/libffmpeg/libavcodec/opt.h18
-rw-r--r--src/libffmpeg/libavcodec/parser.c91
-rw-r--r--src/libffmpeg/libavcodec/pcm.c4
-rw-r--r--src/libffmpeg/libavcodec/ppc/dsputil_altivec.c6
-rw-r--r--src/libffmpeg/libavcodec/ppc/float_altivec.c3
-rw-r--r--src/libffmpeg/libavcodec/qdm2.c16
-rw-r--r--src/libffmpeg/libavcodec/qdrw.c6
-rw-r--r--src/libffmpeg/libavcodec/qtrle.c34
-rw-r--r--src/libffmpeg/libavcodec/rangecoder.c30
-rw-r--r--src/libffmpeg/libavcodec/rpza.c10
-rw-r--r--src/libffmpeg/libavcodec/rv10.c2
-rw-r--r--src/libffmpeg/libavcodec/smacker.c10
-rw-r--r--src/libffmpeg/libavcodec/smc.c6
-rw-r--r--src/libffmpeg/libavcodec/snow.c62
-rw-r--r--src/libffmpeg/libavcodec/svq3.c7
-rw-r--r--src/libffmpeg/libavcodec/truemotion1.c6
-rw-r--r--src/libffmpeg/libavcodec/truemotion2.c16
-rw-r--r--src/libffmpeg/libavcodec/truespeech.c16
-rw-r--r--src/libffmpeg/libavcodec/tscc.c8
-rw-r--r--src/libffmpeg/libavcodec/utils.c32
-rw-r--r--src/libffmpeg/libavcodec/vc1.c41
-rw-r--r--src/libffmpeg/libavcodec/vmdav.c14
-rw-r--r--src/libffmpeg/libavcodec/vp3.c2
-rw-r--r--src/libffmpeg/libavcodec/vp56.h3
-rw-r--r--src/libffmpeg/libavcodec/vp6.c43
-rw-r--r--src/libffmpeg/libavcodec/vqavideo.c30
-rw-r--r--src/libffmpeg/libavcodec/wavpack.c28
-rw-r--r--src/libffmpeg/libavcodec/ws-snd1.c4
-rw-r--r--src/libffmpeg/libavcodec/xan.c10
-rw-r--r--src/libffmpeg/libavcodec/xl.c2
-rw-r--r--src/libffmpeg/libavcodec/zmbv.c6
-rw-r--r--src/libffmpeg/libavutil/avutil.h4
-rw-r--r--src/libffmpeg/libavutil/common.h2
-rw-r--r--src/libffmpeg/libavutil/intreadwrite.h35
-rw-r--r--src/libffmpeg/libavutil/log.c2
-rw-r--r--src/libffmpeg/libavutil/log.h40
71 files changed, 1110 insertions, 750 deletions
diff --git a/src/libffmpeg/audio_decoder.c b/src/libffmpeg/audio_decoder.c
index 8f0425775..7ab1f56b4 100644
--- a/src/libffmpeg/audio_decoder.c
+++ b/src/libffmpeg/audio_decoder.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_decoder.c,v 1.32 2007/01/13 21:19:52 miguelfreitas Exp $
+ * $Id: audio_decoder.c,v 1.33 2007/01/28 18:38:33 miguelfreitas Exp $
*
* xine audio decoder plugin using ffmpeg
*
@@ -291,7 +291,8 @@ static void ff_audio_decode_data (audio_decoder_t *this_gen, buf_element_t *buf)
offset = 0;
while (this->size>0) {
- bytes_consumed = avcodec_decode_audio (this->context,
+ decode_buffer_size = AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ bytes_consumed = avcodec_decode_audio2 (this->context,
(int16_t *)this->decode_buffer,
&decode_buffer_size,
&this->buf[offset],
diff --git a/src/libffmpeg/libavcodec/adpcm.c b/src/libffmpeg/libavcodec/adpcm.c
index ec3fe6f6e..9be4c2274 100644
--- a/src/libffmpeg/libavcodec/adpcm.c
+++ b/src/libffmpeg/libavcodec/adpcm.c
@@ -1100,19 +1100,19 @@ static int adpcm_decode_frame(AVCodecContext *avctx,
}
break;
case CODEC_ID_ADPCM_EA:
- samples_in_chunk = LE_32(src);
+ samples_in_chunk = AV_RL32(src);
if (samples_in_chunk >= ((buf_size - 12) * 2)) {
src += buf_size;
break;
}
src += 4;
- current_left_sample = (int16_t)LE_16(src);
+ current_left_sample = (int16_t)AV_RL16(src);
src += 2;
- previous_left_sample = (int16_t)LE_16(src);
+ previous_left_sample = (int16_t)AV_RL16(src);
src += 2;
- current_right_sample = (int16_t)LE_16(src);
+ current_right_sample = (int16_t)AV_RL16(src);
src += 2;
- previous_right_sample = (int16_t)LE_16(src);
+ previous_right_sample = (int16_t)AV_RL16(src);
src += 2;
for (count1 = 0; count1 < samples_in_chunk/28;count1++) {
diff --git a/src/libffmpeg/libavcodec/alac.c b/src/libffmpeg/libavcodec/alac.c
index 793f71a11..cc87c81e5 100644
--- a/src/libffmpeg/libavcodec/alac.c
+++ b/src/libffmpeg/libavcodec/alac.c
@@ -110,11 +110,11 @@ static int alac_set_info(ALACContext *alac)
ptr += 4; /* alac */
ptr += 4; /* 0 ? */
- if(BE_32(ptr) >= UINT_MAX/4){
+ if(AV_RB32(ptr) >= UINT_MAX/4){
av_log(alac->avctx, AV_LOG_ERROR, "setinfo_max_samples_per_frame too large\n");
return -1;
}
- alac->setinfo_max_samples_per_frame = BE_32(ptr); /* buffer size / 2 ? */
+ alac->setinfo_max_samples_per_frame = AV_RB32(ptr); /* buffer size / 2 ? */
ptr += 4;
alac->setinfo_7a = *ptr++;
alac->setinfo_sample_size = *ptr++;
@@ -122,13 +122,13 @@ static int alac_set_info(ALACContext *alac)
alac->setinfo_rice_initialhistory = *ptr++;
alac->setinfo_rice_kmodifier = *ptr++;
alac->setinfo_7f = *ptr++; // channels?
- alac->setinfo_80 = BE_16(ptr);
+ alac->setinfo_80 = AV_RB16(ptr);
ptr += 2;
- alac->setinfo_82 = BE_32(ptr); // max coded frame size
+ alac->setinfo_82 = AV_RB32(ptr); // max coded frame size
ptr += 4;
- alac->setinfo_86 = BE_32(ptr); // bitrate ?
+ alac->setinfo_86 = AV_RB32(ptr); // bitrate ?
ptr += 4;
- alac->setinfo_8a_rate = BE_32(ptr); // samplerate
+ alac->setinfo_8a_rate = AV_RB32(ptr); // samplerate
ptr += 4;
allocate_buffers(alac);
diff --git a/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c b/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c
index 10a005cd3..ca972e6ed 100644
--- a/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c
+++ b/src/libffmpeg/libavcodec/armv4l/mpegvideo_arm.c
@@ -24,10 +24,13 @@
#include "../avcodec.h"
extern void MPV_common_init_iwmmxt(MpegEncContext *s);
+extern void MPV_common_init_armv5te(MpegEncContext *s);
void MPV_common_init_armv4l(MpegEncContext *s)
{
#ifdef HAVE_IWMMXT
MPV_common_init_iwmmxt(s);
+#elif defined(HAVE_ARMV5TE)
+ MPV_common_init_armv5te(s);
#endif
}
diff --git a/src/libffmpeg/libavcodec/avcodec.h b/src/libffmpeg/libavcodec/avcodec.h
index 7d7678455..ee4eb0122 100644
--- a/src/libffmpeg/libavcodec/avcodec.h
+++ b/src/libffmpeg/libavcodec/avcodec.h
@@ -37,8 +37,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVCODEC_VERSION_INT ((51<<16)+(28<<8)+0)
-#define LIBAVCODEC_VERSION 51.28.0
+#define LIBAVCODEC_VERSION_INT ((51<<16)+(29<<8)+0)
+#define LIBAVCODEC_VERSION 51.29.0
#define LIBAVCODEC_BUILD LIBAVCODEC_VERSION_INT
#define LIBAVCODEC_IDENT "Lavc" AV_STRINGIFY(LIBAVCODEC_VERSION)
@@ -872,7 +872,7 @@ typedef struct AVCodecContext {
int qmax;
/**
- * maximum quantizer difference etween frames.
+ * maximum quantizer difference between frames.
* - encoding: set by user.
* - decoding: unused
*/
@@ -2150,242 +2150,244 @@ typedef struct AVSubtitle {
} AVSubtitle;
extern AVCodec ac3_encoder;
-extern AVCodec mp2_encoder;
-extern AVCodec mp3lame_encoder;
-extern AVCodec oggvorbis_encoder;
+extern AVCodec amr_nb_encoder;
+extern AVCodec amr_wb_encoder;
+extern AVCodec asv1_encoder;
+extern AVCodec asv2_encoder;
+extern AVCodec dvvideo_encoder;
extern AVCodec faac_encoder;
+extern AVCodec ffv1_encoder;
+extern AVCodec ffvhuff_encoder;
extern AVCodec flac_encoder;
+extern AVCodec flashsv_encoder;
+extern AVCodec flv_encoder;
extern AVCodec gif_encoder;
-extern AVCodec xvid_encoder;
-extern AVCodec mpeg1video_encoder;
-extern AVCodec mpeg2video_encoder;
extern AVCodec h261_encoder;
extern AVCodec h263_encoder;
extern AVCodec h263p_encoder;
-extern AVCodec flv_encoder;
-extern AVCodec rv10_encoder;
-extern AVCodec rv20_encoder;
-extern AVCodec dvvideo_encoder;
-extern AVCodec mjpeg_encoder;
-extern AVCodec ljpeg_encoder;
+extern AVCodec h264_encoder;
+extern AVCodec huffyuv_encoder;
extern AVCodec jpegls_encoder;
-extern AVCodec png_encoder;
-extern AVCodec ppm_encoder;
-extern AVCodec pgm_encoder;
-extern AVCodec pgmyuv_encoder;
-extern AVCodec pbm_encoder;
-extern AVCodec pam_encoder;
+extern AVCodec libgsm_encoder;
+extern AVCodec libtheora_encoder;
+extern AVCodec ljpeg_encoder;
+extern AVCodec mdec_encoder;
+extern AVCodec mjpeg_encoder;
+extern AVCodec mp2_encoder;
+extern AVCodec mp3lame_encoder;
+extern AVCodec mpeg1video_encoder;
+extern AVCodec mpeg2video_encoder;
extern AVCodec mpeg4_encoder;
extern AVCodec msmpeg4v1_encoder;
extern AVCodec msmpeg4v2_encoder;
extern AVCodec msmpeg4v3_encoder;
-extern AVCodec wmv1_encoder;
-extern AVCodec wmv2_encoder;
-extern AVCodec huffyuv_encoder;
-extern AVCodec ffvhuff_encoder;
-extern AVCodec h264_encoder;
-extern AVCodec asv1_encoder;
-extern AVCodec asv2_encoder;
-extern AVCodec vcr1_encoder;
-extern AVCodec ffv1_encoder;
+extern AVCodec oggvorbis_encoder;
+extern AVCodec pam_encoder;
+extern AVCodec pbm_encoder;
+extern AVCodec pgm_encoder;
+extern AVCodec pgmyuv_encoder;
+extern AVCodec png_encoder;
+extern AVCodec ppm_encoder;
+extern AVCodec rv10_encoder;
+extern AVCodec rv20_encoder;
extern AVCodec snow_encoder;
-extern AVCodec vorbis_encoder;
-extern AVCodec mdec_encoder;
-extern AVCodec zlib_encoder;
extern AVCodec sonic_encoder;
extern AVCodec sonic_ls_encoder;
extern AVCodec svq1_encoder;
+extern AVCodec vcr1_encoder;
+extern AVCodec vorbis_encoder;
+extern AVCodec wmv1_encoder;
+extern AVCodec wmv2_encoder;
extern AVCodec x264_encoder;
+extern AVCodec xvid_encoder;
+extern AVCodec zlib_encoder;
+extern AVCodec zmbv_encoder;
+extern AVCodec aac_decoder;
+extern AVCodec aasc_decoder;
+extern AVCodec alac_decoder;
+extern AVCodec amr_nb_decoder;
+extern AVCodec amr_wb_decoder;
+extern AVCodec asv1_decoder;
+extern AVCodec asv2_decoder;
+extern AVCodec avs_decoder;
+extern AVCodec bmp_decoder;
+extern AVCodec cavs_decoder;
+extern AVCodec cinepak_decoder;
+extern AVCodec cljr_decoder;
+extern AVCodec cook_decoder;
+extern AVCodec cscd_decoder;
+extern AVCodec cyuv_decoder;
+extern AVCodec dsicinaudio_decoder;
+extern AVCodec dsicinvideo_decoder;
+extern AVCodec dvvideo_decoder;
+extern AVCodec eightbps_decoder;
+extern AVCodec ffv1_decoder;
+extern AVCodec ffvhuff_decoder;
+extern AVCodec flac_decoder;
+extern AVCodec flashsv_decoder;
+extern AVCodec flic_decoder;
+extern AVCodec flv_decoder;
+extern AVCodec fourxm_decoder;
+extern AVCodec fraps_decoder;
extern AVCodec gif_decoder;
-extern AVCodec h263_decoder;
extern AVCodec h261_decoder;
-extern AVCodec mpeg4_decoder;
-extern AVCodec msmpeg4v1_decoder;
-extern AVCodec msmpeg4v2_decoder;
-extern AVCodec msmpeg4v3_decoder;
-extern AVCodec wmv1_decoder;
-extern AVCodec wmv2_decoder;
-extern AVCodec vc1_decoder;
-extern AVCodec wmv3_decoder;
-extern AVCodec mpeg1video_decoder;
-extern AVCodec mpeg2video_decoder;
-extern AVCodec mpegvideo_decoder;
-extern AVCodec mpeg_xvmc_decoder;
+extern AVCodec h263_decoder;
extern AVCodec h263i_decoder;
-extern AVCodec flv_decoder;
-extern AVCodec rv10_decoder;
-extern AVCodec rv20_decoder;
-extern AVCodec rv30_decoder;
-extern AVCodec rv40_decoder;
-extern AVCodec svq1_decoder;
-extern AVCodec svq3_decoder;
-extern AVCodec dvvideo_decoder;
-extern AVCodec wmav1_decoder;
-extern AVCodec wmav2_decoder;
+extern AVCodec h264_decoder;
+extern AVCodec huffyuv_decoder;
+extern AVCodec idcin_decoder;
+extern AVCodec imc_decoder;
+extern AVCodec indeo2_decoder;
+extern AVCodec indeo3_decoder;
+extern AVCodec interplay_dpcm_decoder;
+extern AVCodec interplay_video_decoder;
+extern AVCodec kmvc_decoder;
+extern AVCodec libgsm_decoder;
+extern AVCodec loco_decoder;
+extern AVCodec mace3_decoder;
+extern AVCodec mace6_decoder;
+extern AVCodec mdec_decoder;
extern AVCodec mjpeg_decoder;
extern AVCodec mjpegb_decoder;
-extern AVCodec sp5x_decoder;
-extern AVCodec png_decoder;
+extern AVCodec mmvideo_decoder;
extern AVCodec mp2_decoder;
extern AVCodec mp3_decoder;
extern AVCodec mp3adu_decoder;
extern AVCodec mp3on4_decoder;
-extern AVCodec qdm2_decoder;
-extern AVCodec cook_decoder;
-extern AVCodec truespeech_decoder;
-extern AVCodec tta_decoder;
-extern AVCodec mace3_decoder;
-extern AVCodec mace6_decoder;
-extern AVCodec huffyuv_decoder;
-extern AVCodec ffvhuff_decoder;
-extern AVCodec oggvorbis_decoder;
-extern AVCodec cyuv_decoder;
-extern AVCodec h264_decoder;
-extern AVCodec indeo3_decoder;
-extern AVCodec vp3_decoder;
-extern AVCodec theora_decoder;
-extern AVCodec vp5_decoder;
-extern AVCodec vp6_decoder;
-extern AVCodec vp6f_decoder;
-extern AVCodec amr_nb_decoder;
-extern AVCodec amr_nb_encoder;
-extern AVCodec amr_wb_encoder;
-extern AVCodec amr_wb_decoder;
-extern AVCodec aac_decoder;
+extern AVCodec mpc7_decoder;
+extern AVCodec mpeg1video_decoder;
+extern AVCodec mpeg2video_decoder;
+extern AVCodec mpeg4_decoder;
extern AVCodec mpeg4aac_decoder;
-extern AVCodec asv1_decoder;
-extern AVCodec asv2_decoder;
-extern AVCodec vcr1_decoder;
-extern AVCodec cljr_decoder;
-extern AVCodec ffv1_decoder;
-extern AVCodec snow_decoder;
-extern AVCodec fourxm_decoder;
-extern AVCodec mdec_decoder;
-extern AVCodec roq_decoder;
-extern AVCodec interplay_video_decoder;
-extern AVCodec xan_wc3_decoder;
-extern AVCodec rpza_decoder;
-extern AVCodec cinepak_decoder;
+extern AVCodec mpeg_xvmc_decoder;
+extern AVCodec mpegvideo_decoder;
+extern AVCodec msmpeg4v1_decoder;
+extern AVCodec msmpeg4v2_decoder;
+extern AVCodec msmpeg4v3_decoder;
extern AVCodec msrle_decoder;
extern AVCodec msvideo1_decoder;
-extern AVCodec vqa_decoder;
-extern AVCodec idcin_decoder;
-extern AVCodec eightbps_decoder;
-extern AVCodec smc_decoder;
-extern AVCodec flic_decoder;
-extern AVCodec vmdvideo_decoder;
-extern AVCodec vmdaudio_decoder;
-extern AVCodec truemotion1_decoder;
-extern AVCodec truemotion2_decoder;
extern AVCodec mszh_decoder;
-extern AVCodec zlib_decoder;
+extern AVCodec nuv_decoder;
+extern AVCodec oggvorbis_decoder;
+extern AVCodec png_decoder;
+extern AVCodec qdm2_decoder;
+extern AVCodec qdraw_decoder;
+extern AVCodec qpeg_decoder;
+extern AVCodec qtrle_decoder;
extern AVCodec ra_144_decoder;
extern AVCodec ra_288_decoder;
+extern AVCodec roq_decoder;
extern AVCodec roq_dpcm_decoder;
-extern AVCodec interplay_dpcm_decoder;
-extern AVCodec xan_dpcm_decoder;
+extern AVCodec rpza_decoder;
+extern AVCodec rv10_decoder;
+extern AVCodec rv20_decoder;
+extern AVCodec rv30_decoder;
+extern AVCodec rv40_decoder;
+extern AVCodec shorten_decoder;
+extern AVCodec smackaud_decoder;
+extern AVCodec smacker_decoder;
+extern AVCodec smc_decoder;
+extern AVCodec snow_decoder;
extern AVCodec sol_dpcm_decoder;
extern AVCodec sonic_decoder;
-extern AVCodec qtrle_decoder;
-extern AVCodec flac_decoder;
+extern AVCodec sp5x_decoder;
+extern AVCodec svq1_decoder;
+extern AVCodec svq3_decoder;
+extern AVCodec targa_decoder;
+extern AVCodec theora_decoder;
+extern AVCodec tiertexseqvideo_decoder;
+extern AVCodec tiff_decoder;
+extern AVCodec truemotion1_decoder;
+extern AVCodec truemotion2_decoder;
+extern AVCodec truespeech_decoder;
extern AVCodec tscc_decoder;
-extern AVCodec cscd_decoder;
-extern AVCodec nuv_decoder;
+extern AVCodec tta_decoder;
extern AVCodec ulti_decoder;
-extern AVCodec qdraw_decoder;
-extern AVCodec xl_decoder;
-extern AVCodec qpeg_decoder;
-extern AVCodec shorten_decoder;
-extern AVCodec loco_decoder;
+extern AVCodec vc1_decoder;
+extern AVCodec vcr1_decoder;
+extern AVCodec vmdaudio_decoder;
+extern AVCodec vmdvideo_decoder;
+extern AVCodec vmnc_decoder;
+extern AVCodec vorbis_decoder;
+extern AVCodec vp3_decoder;
+extern AVCodec vp5_decoder;
+extern AVCodec vp6_decoder;
+extern AVCodec vp6f_decoder;
+extern AVCodec vqa_decoder;
+extern AVCodec wavpack_decoder;
+extern AVCodec wmav1_decoder;
+extern AVCodec wmav2_decoder;
+extern AVCodec wmv1_decoder;
+extern AVCodec wmv2_decoder;
+extern AVCodec wmv3_decoder;
extern AVCodec wnv1_decoder;
-extern AVCodec aasc_decoder;
-extern AVCodec alac_decoder;
extern AVCodec ws_snd1_decoder;
-extern AVCodec indeo2_decoder;
-extern AVCodec vorbis_decoder;
-extern AVCodec fraps_decoder;
-extern AVCodec libgsm_encoder;
-extern AVCodec libgsm_decoder;
-extern AVCodec bmp_decoder;
-extern AVCodec mmvideo_decoder;
+extern AVCodec xan_dpcm_decoder;
+extern AVCodec xan_wc3_decoder;
+extern AVCodec xl_decoder;
+extern AVCodec zlib_decoder;
extern AVCodec zmbv_decoder;
-extern AVCodec zmbv_encoder;
-extern AVCodec avs_decoder;
-extern AVCodec smacker_decoder;
-extern AVCodec smackaud_decoder;
-extern AVCodec kmvc_decoder;
-extern AVCodec flashsv_decoder;
-extern AVCodec cavs_decoder;
-extern AVCodec vmnc_decoder;
-extern AVCodec wavpack_decoder;
-extern AVCodec targa_decoder;
-extern AVCodec dsicinvideo_decoder;
-extern AVCodec dsicinaudio_decoder;
-extern AVCodec tiertexseqvideo_decoder;
-extern AVCodec tiff_decoder;
-extern AVCodec imc_decoder;
-extern AVCodec mpc7_decoder;
/* pcm codecs */
#define PCM_CODEC(id, name) \
extern AVCodec name ## _decoder; \
extern AVCodec name ## _encoder
-PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
-PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
-PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
-PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
-PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
-PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
-PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
-PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
+PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
+PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
+PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
+PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
+PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
+PCM_CODEC(CODEC_ID_PCM_S24BE, pcm_s24be);
PCM_CODEC(CODEC_ID_PCM_S24DAUD, pcm_s24daud);
-PCM_CODEC(CODEC_ID_PCM_S16LE, pcm_s16le);
-PCM_CODEC(CODEC_ID_PCM_S16BE, pcm_s16be);
-PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
-PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
-PCM_CODEC(CODEC_ID_PCM_S8, pcm_s8);
-PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
-PCM_CODEC(CODEC_ID_PCM_ALAW, pcm_alaw);
-PCM_CODEC(CODEC_ID_PCM_MULAW, pcm_mulaw);
+PCM_CODEC(CODEC_ID_PCM_S24LE, pcm_s24le);
+PCM_CODEC(CODEC_ID_PCM_S32BE, pcm_s32be);
+PCM_CODEC(CODEC_ID_PCM_S32LE, pcm_s32le);
+PCM_CODEC(CODEC_ID_PCM_U8, pcm_u8);
+PCM_CODEC(CODEC_ID_PCM_U16BE, pcm_u16be);
+PCM_CODEC(CODEC_ID_PCM_U16LE, pcm_u16le);
+PCM_CODEC(CODEC_ID_PCM_U24BE, pcm_u24be);
+PCM_CODEC(CODEC_ID_PCM_U24LE, pcm_u24le);
+PCM_CODEC(CODEC_ID_PCM_U32BE, pcm_u32be);
+PCM_CODEC(CODEC_ID_PCM_U32LE, pcm_u32le);
/* adpcm codecs */
-PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
+PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
+PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
+PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
+PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
+PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK3, adpcm_ima_dk3);
PCM_CODEC(CODEC_ID_ADPCM_IMA_DK4, adpcm_ima_dk4);
-PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
-PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
-PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
-PCM_CODEC(CODEC_ID_ADPCM_4XM, adpcm_4xm);
-PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
-PCM_CODEC(CODEC_ID_ADPCM_ADX, adpcm_adx);
-PCM_CODEC(CODEC_ID_ADPCM_EA, adpcm_ea);
-PCM_CODEC(CODEC_ID_ADPCM_G726, adpcm_g726);
-PCM_CODEC(CODEC_ID_ADPCM_CT, adpcm_ct);
-PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
-PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
-PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
-PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_QT, adpcm_ima_qt);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_WAV, adpcm_ima_wav);
+PCM_CODEC(CODEC_ID_ADPCM_IMA_WS, adpcm_ima_ws);
+PCM_CODEC(CODEC_ID_ADPCM_MS, adpcm_ms);
PCM_CODEC(CODEC_ID_ADPCM_SBPRO_2, adpcm_sbpro_2);
+PCM_CODEC(CODEC_ID_ADPCM_SBPRO_3, adpcm_sbpro_3);
+PCM_CODEC(CODEC_ID_ADPCM_SBPRO_4, adpcm_sbpro_4);
+PCM_CODEC(CODEC_ID_ADPCM_SMJPEG, adpcm_ima_smjpeg);
+PCM_CODEC(CODEC_ID_ADPCM_SWF, adpcm_swf);
+PCM_CODEC(CODEC_ID_ADPCM_XA, adpcm_xa);
+PCM_CODEC(CODEC_ID_ADPCM_YAMAHA, adpcm_yamaha);
#undef PCM_CODEC
/* dummy raw video codec */
-extern AVCodec rawvideo_encoder;
extern AVCodec rawvideo_decoder;
+extern AVCodec rawvideo_encoder;
/* the following codecs use external GPL libs */
extern AVCodec ac3_decoder;
extern AVCodec dts_decoder;
/* subtitles */
-extern AVCodec dvdsub_encoder;
-extern AVCodec dvdsub_decoder;
-extern AVCodec dvbsub_encoder;
extern AVCodec dvbsub_decoder;
+extern AVCodec dvbsub_encoder;
+extern AVCodec dvdsub_decoder;
+extern AVCodec dvdsub_encoder;
/* resample.c */
@@ -2518,18 +2520,21 @@ int avcodec_default_execute(AVCodecContext *c, int (*func)(AVCodecContext *c2, v
*/
int avcodec_open(AVCodecContext *avctx, AVCodec *codec);
+
+attribute_deprecated int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+ int *frame_size_ptr,
+ uint8_t *buf, int buf_size);
/**
* Decode an audio frame.
*
* @param avctx the codec context.
* @param samples output buffer, 16 byte aligned
- * @param frame_size_ptr the output buffer size in bytes, zero if no frame could be compressed
+ * @param frame_size_ptr the output buffer size in bytes (you MUST set this to the allocated size before calling avcodec_decode_audio2()), zero if no frame could be compressed
* @param buf input buffer, 16 byte aligned
* @param buf_size the input buffer size
* @return 0 if successful, -1 if not.
*/
-
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size);
int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
@@ -2625,19 +2630,19 @@ int av_parser_change(AVCodecParserContext *s,
const uint8_t *buf, int buf_size, int keyframe);
void av_parser_close(AVCodecParserContext *s);
-extern AVCodecParser mpegvideo_parser;
-extern AVCodecParser mpeg4video_parser;
+extern AVCodecParser aac_parser;
+extern AVCodecParser ac3_parser;
extern AVCodecParser cavsvideo_parser;
+extern AVCodecParser dvbsub_parser;
+extern AVCodecParser dvdsub_parser;
extern AVCodecParser h261_parser;
extern AVCodecParser h263_parser;
extern AVCodecParser h264_parser;
extern AVCodecParser mjpeg_parser;
-extern AVCodecParser pnm_parser;
+extern AVCodecParser mpeg4video_parser;
extern AVCodecParser mpegaudio_parser;
-extern AVCodecParser ac3_parser;
-extern AVCodecParser dvdsub_parser;
-extern AVCodecParser dvbsub_parser;
-extern AVCodecParser aac_parser;
+extern AVCodecParser mpegvideo_parser;
+extern AVCodecParser pnm_parser;
typedef struct AVBitStreamFilterContext {
diff --git a/src/libffmpeg/libavcodec/avs.c b/src/libffmpeg/libavcodec/avs.c
index 953aea1be..ebfa8adb7 100644
--- a/src/libffmpeg/libavcodec/avs.c
+++ b/src/libffmpeg/libavcodec/avs.c
@@ -74,8 +74,8 @@ avs_decode_frame(AVCodecContext * avctx,
int first, last;
uint32_t *pal = (uint32_t *) avs->picture.data[1];
- first = LE_16(buf);
- last = first + LE_16(buf + 2);
+ first = AV_RL16(buf);
+ last = first + AV_RL16(buf + 2);
buf += 4;
for (i=first; i<last; i++, buf+=3)
pal[i] = (buf[0] << 18) | (buf[1] << 10) | (buf[2] << 2);
diff --git a/src/libffmpeg/libavcodec/bytestream.h b/src/libffmpeg/libavcodec/bytestream.h
index a742fa1c1..ae5438b49 100644
--- a/src/libffmpeg/libavcodec/bytestream.h
+++ b/src/libffmpeg/libavcodec/bytestream.h
@@ -25,13 +25,13 @@
static av_always_inline unsigned int bytestream_get_le32(uint8_t **b)
{
(*b) += 4;
- return LE_32(*b - 4);
+ return AV_RL32(*b - 4);
}
static av_always_inline unsigned int bytestream_get_le16(uint8_t **b)
{
(*b) += 2;
- return LE_16(*b - 2);
+ return AV_RL16(*b - 2);
}
static av_always_inline unsigned int bytestream_get_byte(uint8_t **b)
diff --git a/src/libffmpeg/libavcodec/cabac.h b/src/libffmpeg/libavcodec/cabac.h
index f47406a9e..b990014f6 100644
--- a/src/libffmpeg/libavcodec/cabac.h
+++ b/src/libffmpeg/libavcodec/cabac.h
@@ -462,7 +462,7 @@ static int av_always_inline get_cabac_inline(CABACContext *c, uint8_t * const st
#else /* BRANCHLESS_CABAC_DECODER */
-#if defined CMOV_IS_FAST
+#if defined HAVE_FAST_CMOV
#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
@@ -472,7 +472,7 @@ static int av_always_inline get_cabac_inline(CABACContext *c, uint8_t * const st
"and %%ecx , "tmp" \n\t"\
"sub "tmp" , "low" \n\t"\
"xor %%ecx , "ret" \n\t"
-#else /* CMOV_IS_FAST */
+#else /* HAVE_FAST_CMOV */
#define BRANCHLESS_GET_CABAC_UPDATE(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
"mov "tmp" , %%ecx \n\t"\
"shl $17 , "tmp" \n\t"\
@@ -485,7 +485,7 @@ static int av_always_inline get_cabac_inline(CABACContext *c, uint8_t * const st
"and "tmp" , %%ecx \n\t"\
"sub %%ecx , "low" \n\t"\
"xor "tmp" , "ret" \n\t"
-#endif /* CMOV_IS_FAST */
+#endif /* HAVE_FAST_CMOV */
#define BRANCHLESS_GET_CABAC(ret, cabac, statep, low, lowword, range, tmp, tmpbyte)\
@@ -539,26 +539,26 @@ static int av_always_inline get_cabac_inline(CABACContext *c, uint8_t * const st
c->range -= RangeLPS;
#ifndef BRANCHLESS_CABAC_DECODER
- if(c->low < (c->range<<17)){
+ if(c->low < (c->range<<(CABAC_BITS+1))){
bit= s&1;
*state= ff_h264_mps_state[s];
renorm_cabac_decoder_once(c);
}else{
bit= ff_h264_norm_shift[RangeLPS];
- c->low -= (c->range<<17);
+ c->low -= (c->range<<(CABAC_BITS+1));
*state= ff_h264_lps_state[s];
c->range = RangeLPS<<bit;
c->low <<= bit;
bit= (s&1)^1;
- if(!(c->low & 0xFFFF)){
+ if(!(c->low & CABAC_MASK)){
refill2(c);
}
}
#else /* BRANCHLESS_CABAC_DECODER */
- lps_mask= ((c->range<<17) - c->low)>>31;
+ lps_mask= ((c->range<<(CABAC_BITS+1)) - c->low)>>31;
- c->low -= (c->range<<17) & lps_mask;
+ c->low -= (c->range<<(CABAC_BITS+1)) & lps_mask;
c->range += (RangeLPS - c->range) & lps_mask;
s^=lps_mask;
@@ -620,7 +620,7 @@ static int get_cabac_bypass(CABACContext *c){
if(!(c->low & CABAC_MASK))
refill(c);
- range= c->range<<17;
+ range= c->range<<(CABAC_BITS+1);
if(c->low < range){
return 0;
}else{
@@ -669,7 +669,7 @@ static av_always_inline int get_cabac_bypass_sign(CABACContext *c, int val){
if(!(c->low & CABAC_MASK))
refill(c);
- range= c->range<<17;
+ range= c->range<<(CABAC_BITS+1);
c->low -= range;
mask= c->low >> 31;
range &= mask;
@@ -794,7 +794,7 @@ static int decode_significance_8x8_x86(CABACContext *c, uint8_t *significant_coe
*/
static int get_cabac_terminate(CABACContext *c){
c->range -= 2;
- if(c->low < c->range<<17){
+ if(c->low < c->range<<(CABAC_BITS+1)){
renorm_cabac_decoder_once(c);
return 0;
}else{
diff --git a/src/libffmpeg/libavcodec/cinepak.c b/src/libffmpeg/libavcodec/cinepak.c
index fd95b739e..db0519b5d 100644
--- a/src/libffmpeg/libavcodec/cinepak.c
+++ b/src/libffmpeg/libavcodec/cinepak.c
@@ -90,7 +90,7 @@ static void cinepak_decode_codebook (cvid_codebook_t *codebook,
if ((data + 4) > eod)
break;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -152,7 +152,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
if ((data + 4) > eod)
return -1;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -162,7 +162,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip_t *strip,
if ((data + 4) > eod)
return -1;
- flag = BE_32 (data);
+ flag = AV_RB32 (data);
data += 4;
mask = 0x80000000;
}
@@ -278,8 +278,8 @@ static int cinepak_decode_strip (CinepakContext *s,
return -1;
while ((data + 4) <= eod) {
- chunk_id = BE_16 (&data[0]);
- chunk_size = BE_16 (&data[2]) - 4;
+ chunk_id = AV_RB16 (&data[0]);
+ chunk_size = AV_RB16 (&data[2]) - 4;
if(chunk_size < 0)
return -1;
@@ -328,8 +328,8 @@ static int cinepak_decode (CinepakContext *s)
return -1;
frame_flags = s->data[0];
- num_strips = BE_16 (&s->data[8]);
- encoded_buf_size = ((s->data[1] << 16) | BE_16 (&s->data[2]));
+ num_strips = AV_RB16 (&s->data[8]);
+ encoded_buf_size = ((s->data[1] << 16) | AV_RB16 (&s->data[2]));
/* if this is the first frame, check for deviant Sega FILM data */
if (s->sega_film_skip_bytes == -1) {
@@ -361,13 +361,13 @@ static int cinepak_decode (CinepakContext *s)
if ((s->data + 12) > eod)
return -1;
- s->strips[i].id = BE_16 (s->data);
+ s->strips[i].id = AV_RB16 (s->data);
s->strips[i].y1 = y0;
s->strips[i].x1 = 0;
- s->strips[i].y2 = y0 + BE_16 (&s->data[8]);
+ s->strips[i].y2 = y0 + AV_RB16 (&s->data[8]);
s->strips[i].x2 = s->avctx->width;
- strip_size = BE_16 (&s->data[2]) - 12;
+ strip_size = AV_RB16 (&s->data[2]) - 12;
s->data += 12;
strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
diff --git a/src/libffmpeg/libavcodec/cook.c b/src/libffmpeg/libavcodec/cook.c
index 943addb89..a5bd0a26a 100644
--- a/src/libffmpeg/libavcodec/cook.c
+++ b/src/libffmpeg/libavcodec/cook.c
@@ -54,8 +54,8 @@
#include "cookdata.h"
/* the different Cook versions */
-#define MONO_COOK1 0x1000001
-#define MONO_COOK2 0x1000002
+#define MONO 0x1000001
+#define STEREO 0x1000002
#define JOINT_STEREO 0x1000003
#define MC_COOK 0x2000000 //multichannel Cook, not supported
@@ -277,16 +277,30 @@ static int init_cook_mlt(COOKContext *q) {
/**
* Cook indata decoding, every 32 bits are XORed with 0x37c511f2.
* Why? No idea, some checksum/error detection method maybe.
+ *
+ * Out buffer size: extra bytes are needed to cope with
+ * padding/missalignment.
+ * Subpackets passed to the decoder can contain two, consecutive
+ * half-subpackets, of identical but arbitrary size.
+ * 1234 1234 1234 1234 extraA extraB
+ * Case 1: AAAA BBBB 0 0
+ * Case 2: AAAA ABBB BB-- 3 3
+ * Case 3: AAAA AABB BBBB 2 2
+ * Case 4: AAAA AAAB BBBB BB-- 1 5
+ *
* Nice way to waste CPU cycles.
*
- * @param in pointer to 32bit array of indata
- * @param bits amount of bits
- * @param out pointer to 32bit array of outdata
+ * @param inbuffer pointer to byte array of indata
+ * @param out pointer to byte array of outdata
+ * @param bytes number of bytes
*/
+#define DECODE_BYTES_PAD1(bytes) (3 - ((bytes)+3) % 4)
+#define DECODE_BYTES_PAD2(bytes) ((bytes) % 4 + DECODE_BYTES_PAD1(2 * (bytes)))
-static inline void decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
- int i;
- uint32_t* buf = (uint32_t*) inbuffer;
+static inline int decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
+ int i, off;
+ uint32_t c;
+ uint32_t* buf;
uint32_t* obuf = (uint32_t*) out;
/* FIXME: 64 bit platforms would be able to do 64 bits at a time.
* I'm too lazy though, should be something like
@@ -294,14 +308,14 @@ static inline void decode_bytes(uint8_t* inbuffer, uint8_t* out, int bytes){
* (int64_t)out[i] = 0x37c511f237c511f2^be2me_64(int64_t)in[i]);
* Buffer alignment needs to be checked. */
+ off = (uint32_t)inbuffer % 4;
+ buf = (uint32_t*) (inbuffer - off);
+ c = be2me_32((0x37c511f2 >> (off*8)) | (0x37c511f2 << (32-(off*8))));
+ bytes += 3 + off;
+ for (i = 0; i < bytes/4; i++)
+ obuf[i] = c ^ buf[i];
- for(i=0 ; i<bytes/4 ; i++){
-#ifdef WORDS_BIGENDIAN
- obuf[i] = 0x37c511f2^buf[i];
-#else
- obuf[i] = 0xf211c537^buf[i];
-#endif
- }
+ return off;
}
/**
@@ -948,6 +962,28 @@ static void joint_decode(COOKContext *q, float* mlt_buffer1,
}
/**
+ * First part of subpacket decoding:
+ * decode raw stream bytes and read gain info.
+ *
+ * @param q pointer to the COOKContext
+ * @param inbuffer pointer to raw stream data
+ * @param gain_ptr array of current/prev gain pointers
+ */
+
+static inline void
+decode_bytes_and_gain(COOKContext *q, uint8_t *inbuffer, COOKgain *gain_ptr)
+{
+ int offset;
+
+ offset = decode_bytes(inbuffer, q->decoded_bytes_buffer,
+ q->bits_per_subpacket/8);
+ init_get_bits(&q->gb, q->decoded_bytes_buffer + offset,
+ q->bits_per_subpacket);
+ decode_gain_info(&q->gb, gain_ptr);
+}
+
+
+/**
* Cook subpacket decoding. This function returns one decoded subpacket,
* usually 1024 samples per channel.
*
@@ -970,11 +1006,9 @@ static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,
// }
// av_log(NULL, AV_LOG_ERROR, "\n");
- decode_bytes(inbuffer, q->decoded_bytes_buffer, sub_packet_size);
- init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8);
- decode_gain_info(&q->gb, &q->gain_current);
-
if(q->nb_channels==2 && q->joint_stereo==1){
+ decode_bytes_and_gain(q, inbuffer, &q->gain_current);
+
joint_decode(q, q->decode_buf_ptr[0], q->decode_buf_ptr[2]);
/* Swap buffer pointers. */
@@ -1014,6 +1048,8 @@ static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,
} else if (q->nb_channels==2 && q->joint_stereo==0) {
/* channel 0 */
+ decode_bytes_and_gain(q, inbuffer, &q->gain_current);
+
mono_decode(q, q->decode_buf_ptr2[0]);
tmp_ptr = q->decode_buf_ptr2[0];
@@ -1035,17 +1071,17 @@ static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,
value = lrintf(q->mono_mdct_output[j]);
if(value < -32768) value = -32768;
else if(value > 32767) value = 32767;
- outbuffer[2*j+1] = value;
+ outbuffer[2*j] = value;
}
/* channel 1 */
//av_log(NULL,AV_LOG_ERROR,"bits = %d\n",get_bits_count(&q->gb));
- init_get_bits(&q->gb, q->decoded_bytes_buffer, sub_packet_size*8+q->bits_per_subpacket);
+ decode_bytes_and_gain(q, inbuffer + sub_packet_size/2,
+ &q->gain_channel2[0]);
q->gain_now_ptr = &q->gain_channel2[0];
q->gain_previous_ptr = &q->gain_channel2[1];
- decode_gain_info(&q->gb, &q->gain_channel2[0]);
mono_decode(q, q->decode_buf_ptr[0]);
tmp_ptr = q->decode_buf_ptr[0];
@@ -1067,10 +1103,12 @@ static int decode_subpacket(COOKContext *q, uint8_t *inbuffer,
value = lrintf(q->mono_mdct_output[j]);
if(value < -32768) value = -32768;
else if(value > 32767) value = 32767;
- outbuffer[2*j] = value;
+ outbuffer[2*j+1] = value;
}
} else {
+ decode_bytes_and_gain(q, inbuffer, &q->gain_current);
+
mono_decode(q, q->decode_buf_ptr[0]);
/* Swap buffer pointers. */
@@ -1127,7 +1165,7 @@ static void dump_cook_context(COOKContext *q, COOKextradata *e)
#define PRINT(a,b) av_log(NULL,AV_LOG_ERROR," %s = %d\n", a, b);
av_log(NULL,AV_LOG_ERROR,"COOKextradata\n");
av_log(NULL,AV_LOG_ERROR,"cookversion=%x\n",e->cookversion);
- if (e->cookversion > MONO_COOK2) {
+ if (e->cookversion > STEREO) {
PRINT("js_subband_start",e->js_subband_start);
PRINT("js_vlc_bits",e->js_vlc_bits);
}
@@ -1155,7 +1193,7 @@ static void dump_cook_context(COOKContext *q, COOKextradata *e)
static int cook_decode_init(AVCodecContext *avctx)
{
- COOKextradata *e = avctx->extradata;
+ COOKextradata *e = (COOKextradata *)avctx->extradata;
COOKContext *q = avctx->priv_data;
/* Take care of the codec specific extradata. */
@@ -1199,19 +1237,19 @@ static int cook_decode_init(AVCodecContext *avctx)
/* Initialize version-dependent variables */
av_log(NULL,AV_LOG_DEBUG,"e->cookversion=%x\n",e->cookversion);
switch (e->cookversion) {
- case MONO_COOK1:
+ case MONO:
if (q->nb_channels != 1) {
av_log(avctx,AV_LOG_ERROR,"Container channels != 1, report sample!\n");
return -1;
}
- av_log(avctx,AV_LOG_DEBUG,"MONO_COOK1\n");
+ av_log(avctx,AV_LOG_DEBUG,"MONO\n");
break;
- case MONO_COOK2:
+ case STEREO:
if (q->nb_channels != 1) {
q->joint_stereo = 0;
q->bits_per_subpacket = q->bits_per_subpacket/2;
}
- av_log(avctx,AV_LOG_DEBUG,"MONO_COOK2\n");
+ av_log(avctx,AV_LOG_DEBUG,"STEREO\n");
break;
case JOINT_STEREO:
if (q->nb_channels != 2) {
@@ -1258,9 +1296,21 @@ static int cook_decode_init(AVCodecContext *avctx)
if(avctx->block_align >= UINT_MAX/2)
return -1;
- /* Pad the databuffer with FF_INPUT_BUFFER_PADDING_SIZE,
- this is for the bitstreamreader. */
- if ((q->decoded_bytes_buffer = av_mallocz((avctx->block_align+(4-avctx->block_align%4) + FF_INPUT_BUFFER_PADDING_SIZE)*sizeof(uint8_t))) == NULL)
+ /* Pad the databuffer with:
+ DECODE_BYTES_PAD1 or DECODE_BYTES_PAD2 for decode_bytes(),
+ FF_INPUT_BUFFER_PADDING_SIZE, for the bitstreamreader. */
+ if (q->nb_channels==2 && q->joint_stereo==0) {
+ q->decoded_bytes_buffer =
+ av_mallocz(avctx->block_align/2
+ + DECODE_BYTES_PAD2(avctx->block_align/2)
+ + FF_INPUT_BUFFER_PADDING_SIZE);
+ } else {
+ q->decoded_bytes_buffer =
+ av_mallocz(avctx->block_align
+ + DECODE_BYTES_PAD1(avctx->block_align)
+ + FF_INPUT_BUFFER_PADDING_SIZE);
+ }
+ if (q->decoded_bytes_buffer == NULL)
return -1;
q->decode_buf_ptr[0] = q->decode_buffer_1;
diff --git a/src/libffmpeg/libavcodec/dpcm.c b/src/libffmpeg/libavcodec/dpcm.c
index 99c0cac64..6243881de 100644
--- a/src/libffmpeg/libavcodec/dpcm.c
+++ b/src/libffmpeg/libavcodec/dpcm.c
@@ -179,7 +179,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_ROQ_DPCM:
if (s->channels == 1)
- predictor[0] = LE_16(&buf[6]);
+ predictor[0] = AV_RL16(&buf[6]);
else {
predictor[0] = buf[7] << 8;
predictor[1] = buf[6] << 8;
@@ -200,12 +200,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_INTERPLAY_DPCM:
in = 6; /* skip over the stream mask and stream length */
- predictor[0] = LE_16(&buf[in]);
+ predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0])
output_samples[out++] = predictor[0];
if (s->channels == 2) {
- predictor[1] = LE_16(&buf[in]);
+ predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1])
output_samples[out++] = predictor[1];
@@ -225,11 +225,11 @@ static int dpcm_decode_frame(AVCodecContext *avctx,
case CODEC_ID_XAN_DPCM:
in = 0;
shift[0] = shift[1] = 4;
- predictor[0] = LE_16(&buf[in]);
+ predictor[0] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[0]);
if (s->channels == 2) {
- predictor[1] = LE_16(&buf[in]);
+ predictor[1] = AV_RL16(&buf[in]);
in += 2;
SE_16BIT(predictor[1]);
}
diff --git a/src/libffmpeg/libavcodec/dv.c b/src/libffmpeg/libavcodec/dv.c
index 803d3502d..505c88d49 100644
--- a/src/libffmpeg/libavcodec/dv.c
+++ b/src/libffmpeg/libavcodec/dv.c
@@ -1229,6 +1229,10 @@ static int dvvideo_encode_frame(AVCodecContext *c, uint8_t *buf, int buf_size,
static int dvvideo_close(AVCodecContext *c)
{
+ DVVideoContext *s = c->priv_data;
+
+ if(s->picture.data[0])
+ c->release_buffer(c, &s->picture);
return 0;
}
@@ -1242,10 +1246,7 @@ AVCodec dvvideo_encoder = {
sizeof(DVVideoContext),
dvvideo_init,
dvvideo_encode_frame,
- dvvideo_close,
- NULL,
- CODEC_CAP_DR1,
- NULL
+ .pix_fmts = (enum PixelFormat[]) {PIX_FMT_YUV411P, PIX_FMT_YUV422P, PIX_FMT_YUV420P, -1},
};
#endif // CONFIG_DVVIDEO_ENCODER
diff --git a/src/libffmpeg/libavcodec/dvdata.h b/src/libffmpeg/libavcodec/dvdata.h
index dce4aba98..e688ffbb0 100644
--- a/src/libffmpeg/libavcodec/dvdata.h
+++ b/src/libffmpeg/libavcodec/dvdata.h
@@ -49,7 +49,7 @@ typedef struct DVprofile {
/* for 48Khz, 44.1Khz and 32Khz */
int audio_samples_dist[5];/* how many samples are supposed to be */
/* in each frame in a 5 frames window */
- const uint16_t (*audio_shuffle)[9]; /* PCM shuffling table */
+ const uint8_t (*audio_shuffle)[9]; /* PCM shuffling table */
} DVprofile;
#define NB_DV_VLC 409
@@ -2504,7 +2504,7 @@ static const int dv_iweight_248[64] = {
22017, 25191, 24457, 27962, 22733, 24600, 25971, 29642,
};
-static const uint16_t dv_audio_shuffle525[10][9] = {
+static const uint8_t dv_audio_shuffle525[10][9] = {
{ 0, 30, 60, 20, 50, 80, 10, 40, 70 }, /* 1st channel */
{ 6, 36, 66, 26, 56, 86, 16, 46, 76 },
{ 12, 42, 72, 2, 32, 62, 22, 52, 82 },
@@ -2518,7 +2518,7 @@ static const uint16_t dv_audio_shuffle525[10][9] = {
{ 25, 55, 85, 15, 45, 75, 5, 35, 65 },
};
-static const uint16_t dv_audio_shuffle625[12][9] = {
+static const uint8_t dv_audio_shuffle625[12][9] = {
{ 0, 36, 72, 26, 62, 98, 16, 52, 88}, /* 1st channel */
{ 6, 42, 78, 32, 68, 104, 22, 58, 94},
{ 12, 48, 84, 2, 38, 74, 28, 64, 100},
diff --git a/src/libffmpeg/libavcodec/eval.c b/src/libffmpeg/libavcodec/eval.c
index 961c8b5ac..6ec706991 100644
--- a/src/libffmpeg/libavcodec/eval.c
+++ b/src/libffmpeg/libavcodec/eval.c
@@ -110,7 +110,7 @@ static double av_strtod(const char *name, char **tail) {
if(*next=='B') {
d*=8;
- *next++;
+ next++;
}
}
/* if requested, fill in tail with the position after the last parsed
diff --git a/src/libffmpeg/libavcodec/flac.c b/src/libffmpeg/libavcodec/flac.c
index 6c64ad0a1..1016ed47f 100644
--- a/src/libffmpeg/libavcodec/flac.c
+++ b/src/libffmpeg/libavcodec/flac.c
@@ -225,6 +225,10 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
rice_order = get_bits(&s->gb, 4);
samples= s->blocksize >> rice_order;
+ if (pred_order > samples) {
+ av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples);
+ return -1;
+ }
sample=
i= pred_order;
@@ -454,7 +458,7 @@ static inline int decode_subframe(FLACContext *s, int channel)
return 0;
}
-static int decode_frame(FLACContext *s)
+static int decode_frame(FLACContext *s, int alloc_data_size)
{
int blocksize_code, sample_rate_code, sample_size_code, assignment, i, crc8;
int decorrelation, bps, blocksize, samplerate;
@@ -516,6 +520,9 @@ static int decode_frame(FLACContext *s)
return -1;
}
+ if(blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
+ return -1;
+
if (sample_rate_code == 0){
samplerate= s->samplerate;
}else if ((sample_rate_code > 3) && (sample_rate_code < 12))
@@ -579,6 +586,9 @@ static int flac_decode_frame(AVCodecContext *avctx,
FLACContext *s = avctx->priv_data;
int tmp = 0, i, j = 0, input_buf_size = 0;
int16_t *samples = data;
+ int alloc_data_size= *data_size;
+
+ *data_size=0;
if(s->max_framesize == 0){
s->max_framesize= 65536; // should hopefully be enough for the first header
@@ -617,7 +627,7 @@ static int flac_decode_frame(AVCodecContext *avctx,
goto end; // we may not have enough bits left to decode a frame, so try next time
}
skip_bits(&s->gb, 16);
- if (decode_frame(s) < 0){
+ if (decode_frame(s, alloc_data_size) < 0){
av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
s->bitstream_size=0;
s->bitstream_index=0;
diff --git a/src/libffmpeg/libavcodec/flashsv.c b/src/libffmpeg/libavcodec/flashsv.c
index fea8e2224..9e4aa951a 100644
--- a/src/libffmpeg/libavcodec/flashsv.c
+++ b/src/libffmpeg/libavcodec/flashsv.c
@@ -54,9 +54,7 @@
#include "avcodec.h"
#include "bitstream.h"
-#ifdef CONFIG_ZLIB
#include <zlib.h>
-#endif
typedef struct FlashSVContext {
AVCodecContext *avctx;
@@ -65,9 +63,7 @@ typedef struct FlashSVContext {
int block_width, block_height;
uint8_t* tmpblock;
int block_size;
-#ifdef CONFIG_ZLIB
z_stream zstream;
-#endif
} FlashSVContext;
@@ -90,7 +86,6 @@ static int flashsv_decode_init(AVCodecContext *avctx)
int zret; // Zlib return code
s->avctx = avctx;
-#ifdef CONFIG_ZLIB
s->zstream.zalloc = Z_NULL;
s->zstream.zfree = Z_NULL;
s->zstream.opaque = Z_NULL;
@@ -99,10 +94,6 @@ static int flashsv_decode_init(AVCodecContext *avctx)
av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret);
return 1;
}
-#else
- av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled. Needed for the decoder.\n");
- return 1;
-#endif
avctx->pix_fmt = PIX_FMT_BGR24;
avctx->has_b_frames = 0;
s->frame.data[0] = NULL;
@@ -145,12 +136,12 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
if(s->block_size < s->block_width*s->block_height) {
if (s->tmpblock != NULL)
av_free(s->tmpblock);
- s->block_size = s->block_width*s->block_height;
- if ((s->tmpblock = av_malloc(3*s->block_size)) == NULL) {
+ if ((s->tmpblock = av_malloc(3*s->block_width*s->block_height)) == NULL) {
av_log(avctx, AV_LOG_ERROR, "Can't allocate decompression buffer.\n");
return -1;
}
}
+ s->block_size = s->block_width*s->block_height;
/* init the image size once */
if((avctx->width==0) && (avctx->height==0)){
@@ -198,7 +189,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
/* no change, don't do anything */
} else {
/* decompress block */
-#ifdef CONFIG_ZLIB
int ret = inflateReset(&(s->zstream));
if (ret != Z_OK)
{
@@ -222,10 +212,6 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
av_log(avctx, AV_LOG_ERROR, "error in decompression of block %dx%d: %d\n", i, j, ret);
/* return -1; */
}
-#else
- av_log(avctx, AV_LOG_ERROR, "Zlib support not compiled in.\n");
- return -1;
-#endif
copy_region(s->tmpblock, s->frame.data[0], s->image_height-(hp+hs+1), wp, hs, ws, s->frame.linesize[0]);
skip_bits(&gb, 8*size); /* skip the consumed bits */
}
@@ -247,9 +233,7 @@ static int flashsv_decode_frame(AVCodecContext *avctx,
static int flashsv_decode_end(AVCodecContext *avctx)
{
FlashSVContext *s = (FlashSVContext *)avctx->priv_data;
-#ifdef CONFIG_ZLIB
inflateEnd(&(s->zstream));
-#endif
/* release the frame if needed */
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);
diff --git a/src/libffmpeg/libavcodec/flicvideo.c b/src/libffmpeg/libavcodec/flicvideo.c
index 95cb26ce4..78506eee8 100644
--- a/src/libffmpeg/libavcodec/flicvideo.c
+++ b/src/libffmpeg/libavcodec/flicvideo.c
@@ -87,8 +87,8 @@ static int flic_decode_init(AVCodecContext *avctx)
s->avctx = avctx;
avctx->has_b_frames = 0;
- s->fli_type = LE_16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
- depth = LE_16(&fli_header[12]);
+ s->fli_type = AV_RL16(&fli_header[4]); /* Might be overridden if a Magic Carpet FLC */
+ depth = AV_RL16(&fli_header[12]);
if (depth == 0) {
depth = 8; /* Some FLC generators set depth to zero, when they mean 8Bpp. Fix up here */
@@ -172,18 +172,18 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
pixels = s->frame.data[0];
pixel_limit = s->avctx->height * s->frame.linesize[0];
- frame_size = LE_32(&buf[stream_ptr]);
+ frame_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 6; /* skip the magic number */
- num_chunks = LE_16(&buf[stream_ptr]);
+ num_chunks = AV_RL16(&buf[stream_ptr]);
stream_ptr += 10; /* skip padding */
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size > 0) && (num_chunks > 0)) {
- chunk_size = LE_32(&buf[stream_ptr]);
+ chunk_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 4;
- chunk_type = LE_16(&buf[stream_ptr]);
+ chunk_type = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
switch (chunk_type) {
@@ -200,7 +200,7 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
else
color_shift = 2;
/* set up the palette */
- color_packets = LE_16(&buf[stream_ptr]);
+ color_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
palette_ptr = 0;
for (i = 0; i < color_packets; i++) {
@@ -241,10 +241,10 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case FLI_DELTA:
y_ptr = 0;
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
- line_packets = LE_16(&buf[stream_ptr]);
+ line_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
if ((line_packets & 0xC000) == 0xC000) {
// line skip opcode
@@ -290,12 +290,12 @@ static int flic_decode_frame_8BPP(AVCodecContext *avctx,
case FLI_LC:
/* line compressed */
- starting_line = LE_16(&buf[stream_ptr]);
+ starting_line = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
y_ptr = 0;
y_ptr += starting_line * s->frame.linesize[0];
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
pixel_ptr = y_ptr;
@@ -466,18 +466,18 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixels = s->frame.data[0];
pixel_limit = s->avctx->height * s->frame.linesize[0];
- frame_size = LE_32(&buf[stream_ptr]);
+ frame_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 6; /* skip the magic number */
- num_chunks = LE_16(&buf[stream_ptr]);
+ num_chunks = AV_RL16(&buf[stream_ptr]);
stream_ptr += 10; /* skip padding */
frame_size -= 16;
/* iterate through the chunks */
while ((frame_size > 0) && (num_chunks > 0)) {
- chunk_size = LE_32(&buf[stream_ptr]);
+ chunk_size = AV_RL32(&buf[stream_ptr]);
stream_ptr += 4;
- chunk_type = LE_16(&buf[stream_ptr]);
+ chunk_type = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
switch (chunk_type) {
@@ -492,10 +492,10 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
case FLI_DELTA:
case FLI_DTA_LC:
y_ptr = 0;
- compressed_lines = LE_16(&buf[stream_ptr]);
+ compressed_lines = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
while (compressed_lines > 0) {
- line_packets = LE_16(&buf[stream_ptr]);
+ line_packets = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
if (line_packets < 0) {
line_packets = -line_packets;
@@ -512,7 +512,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
byte_run = (signed char)(buf[stream_ptr++]);
if (byte_run < 0) {
byte_run = -byte_run;
- pixel = LE_16(&buf[stream_ptr]);
+ pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown -= 2) {
@@ -522,7 +522,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
} else {
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++, pixel_countdown--) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
pixel_ptr += 2;
}
@@ -586,12 +586,12 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
* a second pass over the line here, swapping the bytes.
*/
pixel = 0xFF00;
- if (0xFF00 != LE_16(&pixel)) /* Check if its not an LE Target */
+ if (0xFF00 != AV_RL16(&pixel)) /* Check if its not an LE Target */
{
pixel_ptr = y_ptr;
pixel_countdown = s->avctx->width;
while (pixel_countdown > 0) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[pixel_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[pixel_ptr]);
pixel_ptr += 2;
}
}
@@ -611,7 +611,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
while (pixel_countdown > 0) {
byte_run = (signed char)(buf[stream_ptr++]);
if (byte_run > 0) {
- pixel = LE_16(&buf[stream_ptr]);
+ pixel = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
@@ -626,7 +626,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
byte_run = -byte_run;
CHECK_PIXEL_PTR(byte_run);
for (j = 0; j < byte_run; j++) {
- *((signed short*)(&pixels[pixel_ptr])) = LE_16(&buf[stream_ptr]);
+ *((signed short*)(&pixels[pixel_ptr])) = AV_RL16(&buf[stream_ptr]);
stream_ptr += 2;
pixel_ptr += 2;
pixel_countdown--;
@@ -656,7 +656,7 @@ static int flic_decode_frame_15_16BPP(AVCodecContext *avctx,
pixel_countdown = s->avctx->width;
pixel_ptr = 0;
while (pixel_countdown > 0) {
- *((signed short*)(&pixels[y_ptr + pixel_ptr])) = LE_16(&buf[stream_ptr+pixel_ptr]);
+ *((signed short*)(&pixels[y_ptr + pixel_ptr])) = AV_RL16(&buf[stream_ptr+pixel_ptr]);
pixel_ptr += 2;
pixel_countdown--;
}
diff --git a/src/libffmpeg/libavcodec/fraps.c b/src/libffmpeg/libavcodec/fraps.c
index 18d270049..0a4567d05 100644
--- a/src/libffmpeg/libavcodec/fraps.c
+++ b/src/libffmpeg/libavcodec/fraps.c
@@ -138,7 +138,7 @@ static int fraps2_decode_plane(FrapsContext *s, uint8_t *dst, int stride, int w,
for(i = 0; i < 256; i++){
s->nodes[i].sym = i;
- s->nodes[i].count = LE_32(src);
+ s->nodes[i].count = AV_RL32(src);
s->nodes[i].n0 = -2;
if(s->nodes[i].count < 0) {
av_log(s->avctx, AV_LOG_ERROR, "Symbol count < 0\n");
@@ -215,7 +215,7 @@ static int decode_frame(AVCodecContext *avctx,
int i, is_chroma, planes;
- header = LE_32(buf);
+ header = AV_RL32(buf);
version = header & 0xff;
header_size = (header & (1<<30))? 8 : 4; /* bit 30 means pad to 8 bytes */
@@ -337,12 +337,12 @@ static int decode_frame(AVCodecContext *avctx,
}
f->pict_type = FF_I_TYPE;
f->key_frame = 1;
- if ((LE_32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) {
+ if ((AV_RL32(buf) != FPS_TAG)||(buf_size < (planes*1024 + 24))) {
av_log(avctx, AV_LOG_ERROR, "Fraps: error in data stream\n");
return -1;
}
for(i = 0; i < planes; i++) {
- offs[i] = LE_32(buf + 4 + i * 4);
+ offs[i] = AV_RL32(buf + 4 + i * 4);
if(offs[i] >= buf_size || (i && offs[i] <= offs[i - 1] + 1024)) {
av_log(avctx, AV_LOG_ERROR, "Fraps: plane %i offset is out of bounds\n", i);
return -1;
diff --git a/src/libffmpeg/libavcodec/h263.c b/src/libffmpeg/libavcodec/h263.c
index af5fa50e6..27b66a0c8 100644
--- a/src/libffmpeg/libavcodec/h263.c
+++ b/src/libffmpeg/libavcodec/h263.c
@@ -5928,6 +5928,10 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
- ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
s->pb_field_time= ( ROUNDED_DIV(s->time, s->t_frame)
- ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2;
+ if(!s->progressive_sequence){
+ if(s->pp_field_time <= s->pb_field_time || s->pb_field_time <= 1)
+ return FRAME_SKIPPED;
+ }
}
//av_log(s->avctx, AV_LOG_DEBUG, "last nonb %"PRId64" last_base %d time %"PRId64" pp %d pb %d t %d ppf %d pbf %d\n", s->last_non_b_time, s->last_time_base, s->time, s->pp_time, s->pb_time, s->t_frame, s->pp_field_time, s->pb_field_time);
diff --git a/src/libffmpeg/libavcodec/h263dec.c b/src/libffmpeg/libavcodec/h263dec.c
index 66370c179..9246b5217 100644
--- a/src/libffmpeg/libavcodec/h263dec.c
+++ b/src/libffmpeg/libavcodec/h263dec.c
@@ -729,7 +729,7 @@ retry:
decode_slice(s);
while(s->mb_y<s->mb_height){
if(s->msmpeg4_version){
- if(s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
+ if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
break;
}else{
if(ff_h263_resync(s)<0)
diff --git a/src/libffmpeg/libavcodec/h264.c b/src/libffmpeg/libavcodec/h264.c
index d7c48bd4a..d696676f0 100644
--- a/src/libffmpeg/libavcodec/h264.c
+++ b/src/libffmpeg/libavcodec/h264.c
@@ -117,12 +117,12 @@ typedef struct SPS{
* Picture parameter set
*/
typedef struct PPS{
- int sps_id;
+ unsigned int sps_id;
int cabac; ///< entropy_coding_mode_flag
int pic_order_present; ///< pic_order_present_flag
int slice_group_count; ///< num_slice_groups_minus1 + 1
int mb_slice_group_map_type;
- int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
+ unsigned int ref_count[2]; ///< num_ref_idx_l0/1_active_minus1 + 1
int weighted_pred; ///< weighted_pred_flag
int weighted_bipred_idc;
int init_qp; ///< pic_init_qp_minus26 + 26
@@ -274,7 +274,7 @@ typedef struct H264Context{
int mb_field_decoding_flag;
int mb_mbaff; ///< mb_aff_frame && mb_field_decoding_flag
- int sub_mb_type[4];
+ unsigned int sub_mb_type[4];
//POC stuff
int poc_lsb;
@@ -325,12 +325,12 @@ typedef struct H264Context{
/**
* num_ref_idx_l0/1_active_minus1 + 1
*/
- int ref_count[2]; ///< counts frames or fields, depending on current mb mode
+ unsigned int ref_count[2]; ///< counts frames or fields, depending on current mb mode
Picture *short_ref[32];
Picture *long_ref[32];
Picture default_ref_list[2][32];
Picture ref_list[2][48]; ///< 0..15: frame refs, 16..47: mbaff field refs
- Picture *delayed_pic[16]; //FIXME size?
+ Picture *delayed_pic[18]; //FIXME size?
Picture *delayed_output_pic;
/**
@@ -349,6 +349,7 @@ typedef struct H264Context{
GetBitContext *inter_gb_ptr;
DECLARE_ALIGNED_8(DCTELEM, mb[16*24]);
+ DCTELEM mb_padding[256]; ///< as mb is addressed by scantable[i] and scantable is uint8_t we can either check that i is not to large or ensure that there is some unused stuff after mb
/**
* Cabac
@@ -1398,7 +1399,7 @@ static inline void pred_direct_motion(H264Context * const h, int *mb_type){
const int8_t *l1ref0 = &h->ref_list[1][0].ref_index[0][b8_xy];
const int8_t *l1ref1 = &h->ref_list[1][0].ref_index[1][b8_xy];
const int is_b8x8 = IS_8X8(*mb_type);
- int sub_mb_type;
+ unsigned int sub_mb_type;
int i8, i4;
#define MB_TYPE_16x16_OR_INTRA (MB_TYPE_16x16|MB_TYPE_INTRA4x4|MB_TYPE_INTRA16x16|MB_TYPE_INTRA_PCM)
@@ -1780,6 +1781,10 @@ static uint8_t *decode_nal(H264Context *h, uint8_t *src, int *dst_length, int *c
h->rbsp_buffer= av_fast_realloc(h->rbsp_buffer, &h->rbsp_buffer_size, length);
dst= h->rbsp_buffer;
+ if (dst == NULL){
+ return NULL;
+ }
+
//printf("decoding esc\n");
si=di=0;
while(si<length){
@@ -2768,7 +2773,7 @@ static inline void mc_dir_part(H264Context *h, Picture *pic, int n, int square,
const int pic_width = 16*s->mb_width;
const int pic_height = 16*s->mb_height >> MB_MBAFF;
- if(!pic->data[0])
+ if(!pic->data[0]) //FIXME this is unacceptable, some senseable error concealment must be done for missing reference frames
return;
if(mx&7) extra_width -= 3;
@@ -3912,8 +3917,8 @@ static int decode_ref_pic_list_reordering(H264Context *h){
int pred= h->curr_pic_num;
for(index=0; ; index++){
- int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb);
- int pic_id;
+ unsigned int reordering_of_pic_nums_idc= get_ue_golomb(&s->gb);
+ unsigned int pic_id;
int i;
Picture *ref = NULL;
@@ -3927,7 +3932,7 @@ static int decode_ref_pic_list_reordering(H264Context *h){
if(reordering_of_pic_nums_idc<3){
if(reordering_of_pic_nums_idc<2){
- const int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
+ const unsigned int abs_diff_pic_num= get_ue_golomb(&s->gb) + 1;
if(abs_diff_pic_num >= h->max_pic_num){
av_log(h->s.avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
@@ -3949,11 +3954,19 @@ static int decode_ref_pic_list_reordering(H264Context *h){
ref->pic_id= ref->frame_num;
}else{
pic_id= get_ue_golomb(&s->gb); //long_term_pic_idx
+ if(pic_id>31){
+ av_log(h->s.avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
+ return -1;
+ }
ref = h->long_ref[pic_id];
- ref->pic_id= pic_id;
- assert(ref->reference == 3);
- assert(ref->long_ref);
- i=0;
+ if(ref){
+ ref->pic_id= pic_id;
+ assert(ref->reference == 3);
+ assert(ref->long_ref);
+ i=0;
+ }else{
+ i=-1;
+ }
}
if (i < 0) {
@@ -4259,8 +4272,10 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
if(pic) unreference_pic(h, pic);
h->long_ref[ mmco[i].long_index ]= remove_short(h, mmco[i].short_frame_num);
- h->long_ref[ mmco[i].long_index ]->long_ref=1;
- h->long_ref_count++;
+ if (h->long_ref[ mmco[i].long_index ]){
+ h->long_ref[ mmco[i].long_index ]->long_ref=1;
+ h->long_ref_count++;
+ }
break;
case MMCO_LONG2UNUSED:
pic= remove_long(h, mmco[i].long_index);
@@ -4290,7 +4305,7 @@ static int execute_ref_pic_marking(H264Context *h, MMCO *mmco, int mmco_count){
case MMCO_RESET:
while(h->short_ref_count){
pic= remove_short(h, h->short_ref[0]->frame_num);
- unreference_pic(h, pic);
+ if(pic) unreference_pic(h, pic);
}
for(j = 0; j < 16; j++) {
pic= remove_long(h, j);
@@ -4348,14 +4363,15 @@ static int decode_ref_pic_marking(H264Context *h){
}*/
}
if(opcode==MMCO_SHORT2LONG || opcode==MMCO_LONG2UNUSED || opcode==MMCO_LONG || opcode==MMCO_SET_MAX_LONG){
- h->mmco[i].long_index= get_ue_golomb(&s->gb);
- if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ h->mmco[i].long_index >= 16){
+ unsigned int long_index= get_ue_golomb(&s->gb);
+ if(/*h->mmco[i].long_index >= h->long_ref_count || h->long_ref[ h->mmco[i].long_index ] == NULL*/ long_index >= 16){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal long ref in memory management control operation %d\n", opcode);
return -1;
}
+ h->mmco[i].long_index= long_index;
}
- if(opcode > MMCO_LONG){
+ if(opcode > (unsigned)MMCO_LONG){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal memory management control operation %d\n", opcode);
return -1;
}
@@ -4473,10 +4489,11 @@ static int init_poc(H264Context *h){
*/
static int decode_slice_header(H264Context *h){
MpegEncContext * const s = &h->s;
- int first_mb_in_slice, pps_id;
+ unsigned int first_mb_in_slice;
+ unsigned int pps_id;
int num_ref_idx_active_override_flag;
static const uint8_t slice_type_map[5]= {P_TYPE, B_TYPE, I_TYPE, SP_TYPE, SI_TYPE};
- int slice_type;
+ unsigned int slice_type, tmp;
int default_ref_list_done = 0;
s->current_picture.reference= h->nal_ref_idc != 0;
@@ -4505,7 +4522,7 @@ static int decode_slice_header(H264Context *h){
s->pict_type= h->slice_type; // to make a few old func happy, it's wrong though
pps_id= get_ue_golomb(&s->gb);
- if(pps_id>255){
+ if(pps_id>=MAX_PPS_COUNT){
av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
return -1;
}
@@ -4629,12 +4646,15 @@ static int decode_slice_header(H264Context *h){
h->mb_aff_frame = h->sps.mb_aff;
}
}
-
- s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
- s->resync_mb_y = s->mb_y = (first_mb_in_slice / s->mb_width) << h->mb_aff_frame;
- if(s->mb_y >= s->mb_height){
+ assert(s->mb_num == s->mb_width * s->mb_height);
+ if(first_mb_in_slice << h->mb_aff_frame >= s->mb_num ||
+ first_mb_in_slice >= s->mb_num){
+ av_log(h->s.avctx, AV_LOG_ERROR, "first_mb_in_slice overflow\n");
return -1;
}
+ s->resync_mb_x = s->mb_x = first_mb_in_slice % s->mb_width;
+ s->resync_mb_y = s->mb_y = (first_mb_in_slice / s->mb_width) << h->mb_aff_frame;
+ assert(s->mb_y < s->mb_height);
if(s->picture_structure==PICT_FRAME){
h->curr_pic_num= h->frame_num;
@@ -4688,6 +4708,7 @@ static int decode_slice_header(H264Context *h){
if(h->ref_count[0] > 32 || h->ref_count[1] > 32){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow\n");
+ h->ref_count[0]= h->ref_count[1]= 1;
return -1;
}
}
@@ -4714,15 +4735,22 @@ static int decode_slice_header(H264Context *h){
if(FRAME_MBAFF)
fill_mbaff_ref_list(h);
- if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac )
- h->cabac_init_idc = get_ue_golomb(&s->gb);
+ if( h->slice_type != I_TYPE && h->slice_type != SI_TYPE && h->pps.cabac ){
+ tmp = get_ue_golomb(&s->gb);
+ if(tmp > 2){
+ av_log(s->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
+ return -1;
+ }
+ h->cabac_init_idc= tmp;
+ }
h->last_qscale_diff = 0;
- s->qscale = h->pps.init_qp + get_se_golomb(&s->gb);
- if(s->qscale<0 || s->qscale>51){
- av_log(s->avctx, AV_LOG_ERROR, "QP %d out of range\n", s->qscale);
+ tmp = h->pps.init_qp + get_se_golomb(&s->gb);
+ if(tmp>51){
+ av_log(s->avctx, AV_LOG_ERROR, "QP %u out of range\n", tmp);
return -1;
}
+ s->qscale= tmp;
h->chroma_qp = get_chroma_qp(h->pps.chroma_qp_index_offset, s->qscale);
//FIXME qscale / qp ... stuff
if(h->slice_type == SP_TYPE){
@@ -4736,7 +4764,12 @@ static int decode_slice_header(H264Context *h){
h->slice_alpha_c0_offset = 0;
h->slice_beta_offset = 0;
if( h->pps.deblocking_filter_parameters_present ) {
- h->deblocking_filter= get_ue_golomb(&s->gb);
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp > 2){
+ av_log(s->avctx, AV_LOG_ERROR, "deblocking_filter_idc %u out of range\n", tmp);
+ return -1;
+ }
+ h->deblocking_filter= tmp;
if(h->deblocking_filter < 2)
h->deblocking_filter^= 1; // 1<->0
@@ -4762,7 +4795,7 @@ static int decode_slice_header(H264Context *h){
h->emu_edge_height= FRAME_MBAFF ? 0 : h->emu_edge_width;
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%d frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "slice:%d %s mb:%d %c pps:%u frame:%d poc:%d/%d ref:%d/%d qp:%d loop:%d:%d:%d weight:%d%s\n",
h->slice_num,
(s->picture_structure==PICT_FRAME ? "F" : s->picture_structure==PICT_TOP_FIELD ? "T" : "B"),
first_mb_in_slice,
@@ -4856,8 +4889,8 @@ static int decode_residual(H264Context *h, GetBitContext *gb, DCTELEM *block, in
if(total_coeff==0)
return 0;
- if(total_coeff<0) {
- av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff<0)\n", s->mb_x, s->mb_y);
+ if(total_coeff > (unsigned)max_coeff) {
+ av_log(h->s.avctx, AV_LOG_ERROR, "corrupted macroblock %d %d (total_coeff=%d)\n", s->mb_x, s->mb_y, total_coeff);
return -1;
}
@@ -5033,7 +5066,8 @@ static void decode_mb_skip(H264Context *h){
static int decode_mb_cavlc(H264Context *h){
MpegEncContext * const s = &h->s;
const int mb_xy= s->mb_x + s->mb_y*s->mb_stride;
- int mb_type, partition_count, cbp;
+ int partition_count;
+ unsigned int mb_type, cbp;
int dct8x8_allowed= h->pps.transform_8x8_mode;
s->dsp.clear_blocks(h->mb); //FIXME avoid if already clear (move after skip handlong?
@@ -5147,6 +5181,7 @@ decode_intra_mb:
//mb_pred
if(IS_INTRA(mb_type)){
+ int pred_mode;
// init_top_left_availability(h);
if(IS_INTRA4x4(mb_type)){
int i;
@@ -5178,11 +5213,11 @@ decode_intra_mb:
if(h->intra16x16_pred_mode < 0)
return -1;
}
- h->chroma_pred_mode= get_ue_golomb(&s->gb);
- h->chroma_pred_mode= check_intra_pred_mode(h, h->chroma_pred_mode);
- if(h->chroma_pred_mode < 0)
+ pred_mode= check_intra_pred_mode(h, get_ue_golomb(&s->gb));
+ if(pred_mode < 0)
return -1;
+ h->chroma_pred_mode= pred_mode;
}else if(partition_count==4){
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -5190,7 +5225,7 @@ decode_intra_mb:
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=13){
- av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "B sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= b_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -5209,7 +5244,7 @@ decode_intra_mb:
for(i=0; i<4; i++){
h->sub_mb_type[i]= get_ue_golomb(&s->gb);
if(h->sub_mb_type[i] >=4){
- av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %d out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "P sub_mb_type %u out of range at %d %d\n", h->sub_mb_type[i], s->mb_x, s->mb_y);
return -1;
}
sub_partition_count[i]= p_sub_mb_type_info[ h->sub_mb_type[i] ].partition_count;
@@ -5223,7 +5258,12 @@ decode_intra_mb:
for(i=0; i<4; i++){
if(IS_DIRECT(h->sub_mb_type[i])) continue;
if(IS_DIR(h->sub_mb_type[i], 0, list)){
- ref[list][i] = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip?
+ unsigned int tmp = get_te0_golomb(&s->gb, ref_count); //FIXME init to 0 before and skip?
+ if(tmp>=ref_count){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", tmp);
+ return -1;
+ }
+ ref[list][i]= tmp;
}else{
//FIXME
ref[list][i] = -1;
@@ -5292,7 +5332,11 @@ decode_intra_mb:
for(list=0; list<2; list++){
if(h->ref_count[list]>0){
if(IS_DIR(mb_type, 0, list)){
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ unsigned int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, val, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] ], 4, 4, 8, (LIST_NOT_USED&0xFF), 1);
@@ -5315,7 +5359,11 @@ decode_intra_mb:
if(h->ref_count[list]>0){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ unsigned int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, val, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 16*i ], 4, 2, 8, (LIST_NOT_USED&0xFF), 1);
@@ -5341,7 +5389,11 @@ decode_intra_mb:
if(h->ref_count[list]>0){
for(i=0; i<2; i++){
if(IS_DIR(mb_type, i, list)){ //FIXME optimize
- const int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ unsigned int val= get_te0_golomb(&s->gb, h->ref_count[list]);
+ if(val >= h->ref_count[list]){
+ av_log(h->s.avctx, AV_LOG_ERROR, "ref %u overflow\n", val);
+ return -1;
+ }
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, val, 1);
}else
fill_rectangle(&h->ref_cache[list][ scan8[0] + 2*i ], 2, 4, 8, (LIST_NOT_USED&0xFF), 1);
@@ -5370,7 +5422,7 @@ decode_intra_mb:
if(!IS_INTRA16x16(mb_type)){
cbp= get_ue_golomb(&s->gb);
if(cbp > 47){
- av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%d) at %d %d\n", cbp, s->mb_x, s->mb_y);
+ av_log(h->s.avctx, AV_LOG_ERROR, "cbp too large (%u) at %d %d\n", cbp, s->mb_x, s->mb_y);
return -1;
}
@@ -5852,6 +5904,10 @@ static int decode_cabac_mb_ref( H264Context *h, int list, int n ) {
ctx = 4;
else
ctx = 5;
+ if(ref >= 32 /*h->ref_list[list]*/){
+ av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_ref\n");
+ return 0; //FIXME we should return -1 and check the return everywhere
+ }
}
return ref;
}
@@ -5885,6 +5941,10 @@ static int decode_cabac_mb_mvd( H264Context *h, int list, int n, int l ) {
while( get_cabac_bypass( &h->cabac ) ) {
mvd += 1 << k;
k++;
+ if(k>24){
+ av_log(h->s.avctx, AV_LOG_ERROR, "overflow in decode_cabac_mb_mvd\n");
+ return INT_MIN;
+ }
}
while( k-- ) {
if( get_cabac_bypass( &h->cabac ) )
@@ -6224,7 +6284,10 @@ decode_intra_mb:
// FIXME The two following lines get the bitstream position in the cabac
// decode, I think it should be done by a function in cabac.h (or cabac.c).
ptr= h->cabac.bytestream;
- if (h->cabac.low&0x1) ptr-=CABAC_BITS/8;
+ if(h->cabac.low&0x1) ptr--;
+ if(CABAC_BITS==16){
+ if(h->cabac.low&0x1FF) ptr--;
+ }
// The pixels are stored in the same order as levels in h->mb array.
for(y=0; y<16; y++){
@@ -6271,7 +6334,7 @@ decode_intra_mb:
fill_caches(h, mb_type, 0);
if( IS_INTRA( mb_type ) ) {
- int i;
+ int i, pred_mode;
if( IS_INTRA4x4( mb_type ) ) {
if( dct8x8_allowed && decode_cabac_mb_transform_size( h ) ) {
mb_type |= MB_TYPE_8x8DCT;
@@ -6295,10 +6358,11 @@ decode_intra_mb:
if( h->intra16x16_pred_mode < 0 ) return -1;
}
h->chroma_pred_mode_table[mb_xy] =
- h->chroma_pred_mode = decode_cabac_mb_chroma_pre_mode( h );
+ pred_mode = decode_cabac_mb_chroma_pre_mode( h );
- h->chroma_pred_mode= check_intra_pred_mode( h, h->chroma_pred_mode );
- if( h->chroma_pred_mode < 0 ) return -1;
+ pred_mode= check_intra_pred_mode( h, pred_mode );
+ if( pred_mode < 0 ) return -1;
+ h->chroma_pred_mode= pred_mode;
} else if( partition_count == 4 ) {
int i, j, sub_partition_count[4], list, ref[2][4];
@@ -7547,7 +7611,8 @@ static inline void decode_hrd_parameters(H264Context *h, SPS *sps){
static inline int decode_vui_parameters(H264Context *h, SPS *sps){
MpegEncContext * const s = &h->s;
- int aspect_ratio_info_present_flag, aspect_ratio_idc;
+ int aspect_ratio_info_present_flag;
+ unsigned int aspect_ratio_idc;
int nal_hrd_parameters_present_flag, vcl_hrd_parameters_present_flag;
aspect_ratio_info_present_flag= get_bits1(&s->gb);
@@ -7607,13 +7672,21 @@ static inline int decode_vui_parameters(H264Context *h, SPS *sps){
sps->bitstream_restriction_flag = get_bits1(&s->gb);
if(sps->bitstream_restriction_flag){
+ unsigned int num_reorder_frames;
get_bits1(&s->gb); /* motion_vectors_over_pic_boundaries_flag */
get_ue_golomb(&s->gb); /* max_bytes_per_pic_denom */
get_ue_golomb(&s->gb); /* max_bits_per_mb_denom */
get_ue_golomb(&s->gb); /* log2_max_mv_length_horizontal */
get_ue_golomb(&s->gb); /* log2_max_mv_length_vertical */
- sps->num_reorder_frames = get_ue_golomb(&s->gb);
- get_ue_golomb(&s->gb); /* max_dec_frame_buffering */
+ num_reorder_frames= get_ue_golomb(&s->gb);
+ get_ue_golomb(&s->gb); /*max_dec_frame_buffering*/
+
+ if(num_reorder_frames > 16 /*max_dec_frame_buffering || max_dec_frame_buffering > 16*/){
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal num_reorder_frames %d\n", num_reorder_frames);
+ return -1;
+ }
+
+ sps->num_reorder_frames= num_reorder_frames;
}
return 0;
@@ -7669,7 +7742,8 @@ static void decode_scaling_matrices(H264Context *h, SPS *sps, PPS *pps, int is_s
static inline int decode_seq_parameter_set(H264Context *h){
MpegEncContext * const s = &h->s;
int profile_idc, level_idc;
- int sps_id, i;
+ unsigned int sps_id, tmp, mb_width, mb_height;
+ int i;
SPS *sps;
profile_idc= get_bits(&s->gb, 8);
@@ -7681,6 +7755,12 @@ static inline int decode_seq_parameter_set(H264Context *h){
level_idc= get_bits(&s->gb, 8);
sps_id= get_ue_golomb(&s->gb);
+ if (sps_id >= MAX_SPS_COUNT){
+ // ok it has gone out of hand, someone is sending us bad stuff.
+ av_log(h->s.avctx, AV_LOG_ERROR, "illegal sps_id (%d)\n", sps_id);
+ return -1;
+ }
+
sps= &h->sps_buffer[ sps_id ];
sps->profile_idc= profile_idc;
sps->level_idc= level_idc;
@@ -7704,26 +7784,36 @@ static inline int decode_seq_parameter_set(H264Context *h){
sps->delta_pic_order_always_zero_flag= get_bits1(&s->gb);
sps->offset_for_non_ref_pic= get_se_golomb(&s->gb);
sps->offset_for_top_to_bottom_field= get_se_golomb(&s->gb);
- sps->poc_cycle_length= get_ue_golomb(&s->gb);
+ tmp= get_ue_golomb(&s->gb);
+
+ if(tmp >= sizeof(sps->offset_for_ref_frame) / sizeof(sps->offset_for_ref_frame[0])){
+ av_log(h->s.avctx, AV_LOG_ERROR, "poc_cycle_length overflow %u\n", tmp);
+ return -1;
+ }
+ sps->poc_cycle_length= tmp;
for(i=0; i<sps->poc_cycle_length; i++)
sps->offset_for_ref_frame[i]= get_se_golomb(&s->gb);
- }
- if(sps->poc_type > 2){
+ }else if(sps->poc_type != 2){
av_log(h->s.avctx, AV_LOG_ERROR, "illegal POC type %d\n", sps->poc_type);
return -1;
}
- sps->ref_frame_count= get_ue_golomb(&s->gb);
- if(sps->ref_frame_count > MAX_PICTURE_COUNT-2){
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp > MAX_PICTURE_COUNT-2){
av_log(h->s.avctx, AV_LOG_ERROR, "too many reference frames\n");
}
+ sps->ref_frame_count= tmp;
sps->gaps_in_frame_num_allowed_flag= get_bits1(&s->gb);
- sps->mb_width= get_ue_golomb(&s->gb) + 1;
- sps->mb_height= get_ue_golomb(&s->gb) + 1;
- if((unsigned)sps->mb_width >= INT_MAX/16 || (unsigned)sps->mb_height >= INT_MAX/16 ||
- avcodec_check_dimensions(NULL, 16*sps->mb_width, 16*sps->mb_height))
+ mb_width= get_ue_golomb(&s->gb) + 1;
+ mb_height= get_ue_golomb(&s->gb) + 1;
+ if(mb_width >= INT_MAX/16 || mb_height >= INT_MAX/16 ||
+ avcodec_check_dimensions(NULL, 16*mb_width, 16*mb_height)){
+ av_log(h->s.avctx, AV_LOG_ERROR, "mb_width/height overflow\n");
return -1;
+ }
+ sps->mb_width = mb_width;
+ sps->mb_height= mb_height;
sps->frame_mbs_only_flag= get_bits1(&s->gb);
if(!sps->frame_mbs_only_flag)
@@ -7761,7 +7851,7 @@ static inline int decode_seq_parameter_set(H264Context *h){
decode_vui_parameters(h, sps);
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%d profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "sps:%u profile:%d/%d poc:%d ref:%d %dx%d %s %s crop:%d/%d/%d/%d %s\n",
sps_id, sps->profile_idc, sps->level_idc,
sps->poc_type,
sps->ref_frame_count,
@@ -7778,10 +7868,22 @@ static inline int decode_seq_parameter_set(H264Context *h){
static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
MpegEncContext * const s = &h->s;
- int pps_id= get_ue_golomb(&s->gb);
- PPS *pps= &h->pps_buffer[pps_id];
+ unsigned int tmp, pps_id= get_ue_golomb(&s->gb);
+ PPS *pps;
+
+ if(pps_id>=MAX_PPS_COUNT){
+ av_log(h->s.avctx, AV_LOG_ERROR, "pps_id out of range\n");
+ return -1;
+ }
+ pps = &h->pps_buffer[pps_id];
+
+ tmp= get_ue_golomb(&s->gb);
+ if(tmp>=MAX_SPS_COUNT){
+ av_log(h->s.avctx, AV_LOG_ERROR, "sps_id out of range\n");
+ return -1;
+ }
+ pps->sps_id= tmp;
- pps->sps_id= get_ue_golomb(&s->gb);
pps->cabac= get_bits1(&s->gb);
pps->pic_order_present= get_bits1(&s->gb);
pps->slice_group_count= get_ue_golomb(&s->gb) + 1;
@@ -7826,6 +7928,7 @@ static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
pps->ref_count[1]= get_ue_golomb(&s->gb) + 1;
if(pps->ref_count[0] > 32 || pps->ref_count[1] > 32){
av_log(h->s.avctx, AV_LOG_ERROR, "reference overflow (pps)\n");
+ pps->ref_count[0]= pps->ref_count[1]= 1;
return -1;
}
@@ -7850,7 +7953,7 @@ static inline int decode_picture_parameter_set(H264Context *h, int bit_length){
}
if(s->avctx->debug&FF_DEBUG_PICT_INFO){
- av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%d sps:%d %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s %s\n",
+ av_log(h->s.avctx, AV_LOG_DEBUG, "pps:%u sps:%u %s slice_groups:%d ref:%d/%d %s qp:%d/%d/%d %s %s %s %s\n",
pps_id, pps->sps_id,
pps->cabac ? "CABAC" : "CAVLC",
pps->slice_group_count,
@@ -7984,7 +8087,7 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
nalsize = 0;
for(i = 0; i < h->nal_length_size; i++)
nalsize = (nalsize << 8) | buf[buf_index++];
- if(nalsize <= 1){
+ if(nalsize <= 1 || nalsize > buf_size){
if(nalsize == 1){
buf_index++;
continue;
@@ -8007,6 +8110,9 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
}
ptr= decode_nal(h, buf + buf_index, &dst_length, &consumed, h->is_avc ? nalsize : buf_size - buf_index);
+ if (ptr==NULL || dst_length <= 0){
+ return -1;
+ }
while(ptr[dst_length - 1] == 0 && dst_length > 1)
dst_length--;
bit_length= 8*dst_length - decode_rbsp_trailing(ptr + dst_length - 1);
@@ -8064,6 +8170,7 @@ static int decode_nal_units(H264Context *h, uint8_t *buf, int buf_size){
h->inter_gb_ptr= &h->inter_gb;
if(h->redundant_pic_count==0 && h->intra_gb_ptr && s->data_partitioning
+ && s->context_initialized
&& s->hurry_up < 5
&& (avctx->skip_frame < AVDISCARD_NONREF || h->nal_ref_idc)
&& (avctx->skip_frame < AVDISCARD_BIDIR || h->slice_type!=B_TYPE)
@@ -8184,7 +8291,7 @@ static int decode_frame(AVCodecContext *avctx,
cnt = *(p+5) & 0x1f; // Number of sps
p += 6;
for (i = 0; i < cnt; i++) {
- nalsize = BE_16(p) + 2;
+ nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) < 0) {
av_log(avctx, AV_LOG_ERROR, "Decoding sps %d from avcC failed\n", i);
return -1;
@@ -8194,7 +8301,7 @@ static int decode_frame(AVCodecContext *avctx,
// Decode pps from avcC
cnt = *(p++); // Number of pps
for (i = 0; i < cnt; i++) {
- nalsize = BE_16(p) + 2;
+ nalsize = AV_RB16(p) + 2;
if(decode_nal_units(h, p, nalsize) != nalsize) {
av_log(avctx, AV_LOG_ERROR, "Decoding pps %d from avcC failed\n", i);
return -1;
@@ -8242,6 +8349,9 @@ static int decode_frame(AVCodecContext *avctx,
pics = 0;
while(h->delayed_pic[pics]) pics++;
+
+ assert(pics+1 < sizeof(h->delayed_pic) / sizeof(h->delayed_pic[0]));
+
h->delayed_pic[pics++] = cur;
if(cur->reference == 0)
cur->reference = 1;
diff --git a/src/libffmpeg/libavcodec/i386/idct_mmx.c b/src/libffmpeg/libavcodec/i386/idct_mmx.c
index ba595845a..4c548fdce 100644
--- a/src/libffmpeg/libavcodec/i386/idct_mmx.c
+++ b/src/libffmpeg/libavcodec/i386/idct_mmx.c
@@ -15,7 +15,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
+ * along with mpeg2dec; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
diff --git a/src/libffmpeg/libavcodec/imgconvert.c b/src/libffmpeg/libavcodec/imgconvert.c
index d5b4cdca0..b2305cd63 100644
--- a/src/libffmpeg/libavcodec/imgconvert.c
+++ b/src/libffmpeg/libavcodec/imgconvert.c
@@ -2252,48 +2252,61 @@ int img_crop(AVPicture *dst, const AVPicture *src,
/**
* Pad image
*/
-int img_pad(AVPicture *dst, const AVPicture *src, int height, int width, int pix_fmt,
- int padtop, int padbottom, int padleft, int padright, int *color)
+int img_pad(AVPicture *dst, const AVPicture *src, int height, int width,
+ int pix_fmt, int padtop, int padbottom, int padleft, int padright,
+ int *color)
{
- uint8_t *optr, *iptr;
+ uint8_t *optr;
int y_shift;
int x_shift;
int yheight;
int i, y;
- if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB || !is_yuv_planar(&pix_fmt_info[pix_fmt]))
- return -1;
+ if (pix_fmt < 0 || pix_fmt >= PIX_FMT_NB ||
+ !is_yuv_planar(&pix_fmt_info[pix_fmt])) return -1;
for (i = 0; i < 3; i++) {
x_shift = i ? pix_fmt_info[pix_fmt].x_chroma_shift : 0;
y_shift = i ? pix_fmt_info[pix_fmt].y_chroma_shift : 0;
if (padtop || padleft) {
- memset(dst->data[i], color[i], dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
+ memset(dst->data[i], color[i],
+ dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift));
}
- if (padleft || padright || src) {
- if (src) { /* first line */
- iptr = src->data[i];
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (padleft >> x_shift);
- memcpy(optr, iptr, src->linesize[i]);
- iptr += src->linesize[i];
+ if (padleft || padright) {
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (dst->linesize[i] - (padright >> x_shift));
+ yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
+ for (y = 0; y < yheight; y++) {
+ memset(optr, color[i], (padleft + padright) >> x_shift);
+ optr += dst->linesize[i];
}
- optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) + (dst->linesize[i] - (padright >> x_shift));
+ }
+
+ if (src) { /* first line */
+ uint8_t *iptr = src->data[i];
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (padleft >> x_shift);
+ memcpy(optr, iptr, src->linesize[i]);
+ iptr += src->linesize[i];
+ optr = dst->data[i] + dst->linesize[i] * (padtop >> y_shift) +
+ (dst->linesize[i] - (padright >> x_shift));
yheight = (height - 1 - (padtop + padbottom)) >> y_shift;
for (y = 0; y < yheight; y++) {
memset(optr, color[i], (padleft + padright) >> x_shift);
- if (src) {
- memcpy(optr + ((padleft + padright) >> x_shift), iptr, src->linesize[i]);
- iptr += src->linesize[i];
- }
+ memcpy(optr + ((padleft + padright) >> x_shift), iptr,
+ src->linesize[i]);
+ iptr += src->linesize[i];
optr += dst->linesize[i];
}
}
if (padbottom || padright) {
- optr = dst->data[i] + dst->linesize[i] * ((height - padbottom) >> y_shift) - (padright >> x_shift);
- memset(optr, color[i], dst->linesize[i] * (padbottom >> y_shift) + (padright >> x_shift));
+ optr = dst->data[i] + dst->linesize[i] *
+ ((height - padbottom) >> y_shift) - (padright >> x_shift);
+ memset(optr, color[i],dst->linesize[i] *
+ (padbottom >> y_shift) + (padright >> x_shift));
}
}
return 0;
diff --git a/src/libffmpeg/libavcodec/imgresample.c b/src/libffmpeg/libavcodec/imgresample.c
index ce1a05ce4..adcfd0481 100644
--- a/src/libffmpeg/libavcodec/imgresample.c
+++ b/src/libffmpeg/libavcodec/imgresample.c
@@ -672,6 +672,8 @@ struct SwsContext *sws_getContext(int srcW, int srcH, int srcFormat,
void sws_freeContext(struct SwsContext *ctx)
{
+ if (!ctx)
+ return;
if ((ctx->resampling_ctx->iwidth != ctx->resampling_ctx->owidth) ||
(ctx->resampling_ctx->iheight != ctx->resampling_ctx->oheight)) {
img_resample_close(ctx->resampling_ctx);
diff --git a/src/libffmpeg/libavcodec/kmvc.c b/src/libffmpeg/libavcodec/kmvc.c
index e8f39fca1..28dc01483 100644
--- a/src/libffmpeg/libavcodec/kmvc.c
+++ b/src/libffmpeg/libavcodec/kmvc.c
@@ -368,13 +368,13 @@ static int decode_init(AVCodecContext * avctx)
av_log(NULL, 0, "Extradata missing, decoding may not work properly...\n");
c->palsize = 127;
} else {
- c->palsize = LE_16(avctx->extradata + 10);
+ c->palsize = AV_RL16(avctx->extradata + 10);
}
if (avctx->extradata_size == 1036) { // palette in extradata
uint8_t *src = avctx->extradata + 12;
for (i = 0; i < 256; i++) {
- c->pal[i] = LE_32(src);
+ c->pal[i] = AV_RL32(src);
src += 4;
}
c->setpal = 1;
diff --git a/src/libffmpeg/libavcodec/loco.c b/src/libffmpeg/libavcodec/loco.c
index 2ec850ed0..b1f99f425 100644
--- a/src/libffmpeg/libavcodec/loco.c
+++ b/src/libffmpeg/libavcodec/loco.c
@@ -237,20 +237,20 @@ static int decode_init(AVCodecContext *avctx){
avctx->extradata_size);
return -1;
}
- version = LE_32(avctx->extradata);
+ version = AV_RL32(avctx->extradata);
switch(version) {
case 1:
l->lossy = 0;
break;
case 2:
- l->lossy = LE_32(avctx->extradata + 8);
+ l->lossy = AV_RL32(avctx->extradata + 8);
break;
default:
- l->lossy = LE_32(avctx->extradata + 8);
+ l->lossy = AV_RL32(avctx->extradata + 8);
av_log(avctx, AV_LOG_INFO, "This is LOCO codec version %i, please upload file for study\n", version);
}
- l->mode = LE_32(avctx->extradata + 4);
+ l->mode = AV_RL32(avctx->extradata + 4);
switch(l->mode) {
case LOCO_CYUY2: case LOCO_YUY2: case LOCO_UYVY:
avctx->pix_fmt = PIX_FMT_YUV422P;
diff --git a/src/libffmpeg/libavcodec/lzo.c b/src/libffmpeg/libavcodec/lzo.c
index 015c80d0d..0ee7eca04 100644
--- a/src/libffmpeg/libavcodec/lzo.c
+++ b/src/libffmpeg/libavcodec/lzo.c
@@ -26,7 +26,7 @@
//! define if we may write up to 12 bytes beyond the output buffer
#define OUTBUF_PADDED 1
-//! define if we may read up to 4 bytes beyond the input buffer
+//! define if we may read up to 8 bytes beyond the input buffer
#define INBUF_PADDED 1
typedef struct LZOContext {
uint8_t *in, *in_end;
@@ -45,6 +45,12 @@ static inline int get_byte(LZOContext *c) {
return 1;
}
+#ifdef INBUF_PADDED
+#define GETB(c) (*(c).in++)
+#else
+#define GETB(c) get_byte(&(c))
+#endif
+
/**
* \brief decode a length value in the coding used by lzo
* \param x previous byte value
@@ -67,11 +73,11 @@ static inline int get_len(LZOContext *c, int x, int mask) {
static inline void copy(LZOContext *c, int cnt) {
register uint8_t *src = c->in;
register uint8_t *dst = c->out;
- if (src + cnt > c->in_end) {
+ if (src + cnt > c->in_end || src + cnt < src) {
cnt = c->in_end - src;
c->error |= LZO_INPUT_DEPLETED;
}
- if (dst + cnt > c->out_end) {
+ if (dst + cnt > c->out_end || dst + cnt < dst) {
cnt = c->out_end - dst;
c->error |= LZO_OUTPUT_FULL;
}
@@ -101,11 +107,11 @@ static inline void copy(LZOContext *c, int cnt) {
static inline void copy_backptr(LZOContext *c, int back, int cnt) {
register uint8_t *src = &c->out[-back];
register uint8_t *dst = c->out;
- if (src < c->out_start) {
+ if (src < c->out_start || src > dst) {
c->error |= LZO_INVALID_BACKPTR;
return;
}
- if (dst + cnt > c->out_end) {
+ if (dst + cnt > c->out_end || dst + cnt < dst) {
cnt = c->out_end - dst;
c->error |= LZO_OUTPUT_FULL;
}
@@ -170,10 +176,10 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
c.out = c.out_start = out;
c.out_end = (uint8_t *)out + * outlen;
c.error = 0;
- x = get_byte(&c);
+ x = GETB(c);
if (x > 17) {
copy(&c, x - 17);
- x = get_byte(&c);
+ x = GETB(c);
if (x < 16) c.error |= LZO_ERROR;
}
while (!c.error) {
@@ -181,16 +187,16 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
if (x >> 4) {
if (x >> 6) {
cnt = (x >> 5) - 1;
- back = (get_byte(&c) << 3) + ((x >> 2) & 7) + 1;
+ back = (GETB(c) << 3) + ((x >> 2) & 7) + 1;
} else if (x >> 5) {
cnt = get_len(&c, x, 31);
- x = get_byte(&c);
- back = (get_byte(&c) << 6) + (x >> 2) + 1;
+ x = GETB(c);
+ back = (GETB(c) << 6) + (x >> 2) + 1;
} else {
cnt = get_len(&c, x, 7);
back = (1 << 14) + ((x & 8) << 11);
- x = get_byte(&c);
- back += (get_byte(&c) << 6) + (x >> 2);
+ x = GETB(c);
+ back += (GETB(c) << 6) + (x >> 2);
if (back == (1 << 14)) {
if (cnt != 1)
c.error |= LZO_ERROR;
@@ -202,15 +208,15 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
case COPY:
cnt = get_len(&c, x, 15);
copy(&c, cnt + 3);
- x = get_byte(&c);
+ x = GETB(c);
if (x >> 4)
continue;
cnt = 1;
- back = (1 << 11) + (get_byte(&c) << 2) + (x >> 2) + 1;
+ back = (1 << 11) + (GETB(c) << 2) + (x >> 2) + 1;
break;
case BACKPTR:
cnt = 0;
- back = (get_byte(&c) << 2) + (x >> 2) + 1;
+ back = (GETB(c) << 2) + (x >> 2) + 1;
break;
}
copy_backptr(&c, back, cnt + 2);
@@ -218,9 +224,45 @@ int lzo1x_decode(void *out, int *outlen, void *in, int *inlen) {
state = cnt ? BACKPTR : COPY;
if (cnt)
copy(&c, cnt);
- x = get_byte(&c);
+ x = GETB(c);
+ if (c.in > c.in_end)
+ c.error |= LZO_INPUT_DEPLETED;
}
*inlen = c.in_end - c.in;
+ if (c.in > c.in_end)
+ *inlen = 0;
*outlen = c.out_end - c.out;
return c.error;
}
+
+#ifdef TEST
+#include <stdio.h>
+#include <lzo/lzo1x.h>
+#include "log.h"
+#define MAXSZ (10*1024*1024)
+int main(int argc, char *argv[]) {
+ FILE *in = fopen(argv[1], "rb");
+ uint8_t *orig = av_malloc(MAXSZ + 16);
+ uint8_t *comp = av_malloc(2*MAXSZ + 16);
+ uint8_t *decomp = av_malloc(MAXSZ + 16);
+ size_t s = fread(orig, 1, MAXSZ, in);
+ lzo_uint clen = 0;
+ long tmp[LZO1X_MEM_COMPRESS];
+ int inlen, outlen;
+ int i;
+ av_log_level = AV_LOG_DEBUG;
+ lzo1x_999_compress(orig, s, comp, &clen, tmp);
+ for (i = 0; i < 300; i++) {
+START_TIMER
+ inlen = clen; outlen = MAXSZ;
+ if (lzo1x_decode(decomp, &outlen, comp, &inlen))
+ av_log(NULL, AV_LOG_ERROR, "decompression error\n");
+STOP_TIMER("lzod")
+ }
+ if (memcmp(orig, decomp, s))
+ av_log(NULL, AV_LOG_ERROR, "decompression incorrect\n");
+ else
+ av_log(NULL, AV_LOG_ERROR, "decompression ok\n");
+ return 0;
+}
+#endif
diff --git a/src/libffmpeg/libavcodec/lzo.h b/src/libffmpeg/libavcodec/lzo.h
index 4d00dd721..5b3d98f40 100644
--- a/src/libffmpeg/libavcodec/lzo.h
+++ b/src/libffmpeg/libavcodec/lzo.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#ifndef _LZO_H
+#ifndef LZO_H
#define LZO_H
#define LZO_INPUT_DEPLETED 1
@@ -27,7 +27,7 @@
#define LZO_INVALID_BACKPTR 4
#define LZO_ERROR 8
-#define LZO_INPUT_PADDING 4
+#define LZO_INPUT_PADDING 8
#define LZO_OUTPUT_PADDING 12
int lzo1x_decode(void *out, int *outlen, void *in, int *inlen);
diff --git a/src/libffmpeg/libavcodec/mjpeg.c b/src/libffmpeg/libavcodec/mjpeg.c
index 8352782c4..3d4dd9cc4 100644
--- a/src/libffmpeg/libavcodec/mjpeg.c
+++ b/src/libffmpeg/libavcodec/mjpeg.c
@@ -2547,12 +2547,12 @@ static int mjpega_dump_header(AVBitStreamFilterContext *bsfc, AVCodecContext *av
break;
case SOS:
bytestream_put_be32(&poutbufp, i + 46); /* scan off */
- bytestream_put_be32(&poutbufp, i + 46 + BE_16(buf + i + 2)); /* data off */
+ bytestream_put_be32(&poutbufp, i + 46 + AV_RB16(buf + i + 2)); /* data off */
bytestream_put_buffer(&poutbufp, buf + 2, buf_size - 2); /* skip already written SOI */
*poutbuf_size = poutbufp - *poutbuf;
return 1;
case APP1:
- if (i + 8 < buf_size && LE_32(buf + i + 8) == ff_get_fourcc("mjpg")) {
+ if (i + 8 < buf_size && AV_RL32(buf + i + 8) == ff_get_fourcc("mjpg")) {
av_log(avctx, AV_LOG_ERROR, "bitstream already formatted\n");
memcpy(*poutbuf, buf, buf_size);
*poutbuf_size = buf_size;
diff --git a/src/libffmpeg/libavcodec/mmvideo.c b/src/libffmpeg/libavcodec/mmvideo.c
index 07d3f3fc5..7ba1321cb 100644
--- a/src/libffmpeg/libavcodec/mmvideo.c
+++ b/src/libffmpeg/libavcodec/mmvideo.c
@@ -110,7 +110,7 @@ static void mm_decode_intra(MmContext * s, int half_horiz, int half_vert, const
static void mm_decode_inter(MmContext * s, int half_horiz, int half_vert, const uint8_t *buf, int buf_size)
{
- const int data_ptr = 2 + LE_16(&buf[0]);
+ const int data_ptr = 2 + AV_RL16(&buf[0]);
int d, r, y;
d = data_ptr; r = 2; y = 0;
@@ -162,7 +162,7 @@ static int mm_decode_frame(AVCodecContext *avctx,
palette_control->palette_changed = 0;
}
- type = LE_16(&buf[0]);
+ type = AV_RL16(&buf[0]);
buf += MM_PREAMBLE_SIZE;
buf_size -= MM_PREAMBLE_SIZE;
diff --git a/src/libffmpeg/libavcodec/mpeg12.c b/src/libffmpeg/libavcodec/mpeg12.c
index 8af7bdfa7..63fb00feb 100644
--- a/src/libffmpeg/libavcodec/mpeg12.c
+++ b/src/libffmpeg/libavcodec/mpeg12.c
@@ -3185,6 +3185,10 @@ static int mpeg_decode_frame(AVCodecContext *avctx,
if(mpeg_field_start(s2) < 0)
return -1;
}
+ if(!s2->current_picture_ptr){
+ av_log(avctx, AV_LOG_ERROR, "current_picture not initalized\n");
+ return -1;
+ }
if(avctx->thread_count > 1){
int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
diff --git a/src/libffmpeg/libavcodec/mpegvideo.c b/src/libffmpeg/libavcodec/mpegvideo.c
index a33485549..87c913efa 100644
--- a/src/libffmpeg/libavcodec/mpegvideo.c
+++ b/src/libffmpeg/libavcodec/mpegvideo.c
@@ -1103,7 +1103,7 @@ int MPV_encode_init(AVCodecContext *avctx)
}
if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){
- av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n");
+ av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet, set threshold to 1000000000\n");
return -1;
}
@@ -1553,6 +1553,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
/* mark&release old frames */
if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
+ if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
/* release forgotten pictures */
@@ -1565,6 +1566,7 @@ int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
}
}
}
+ }
}
alloc:
if(!s->encoding){
@@ -1602,7 +1604,6 @@ alloc:
copy_picture(&s->current_picture, s->current_picture_ptr);
- if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
if (s->pict_type != B_TYPE) {
s->last_picture_ptr= s->next_picture_ptr;
if(!s->dropable)
@@ -1617,7 +1618,7 @@ alloc:
if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
- if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL)){
+ if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable){
av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference
goto alloc;
@@ -1636,7 +1637,6 @@ alloc:
s->next_picture.linesize[i] *=2;
}
}
- }
s->hurry_up= s->avctx->hurry_up;
s->error_resilience= avctx->error_resilience;
@@ -2275,15 +2275,6 @@ static int estimate_best_b_count(MpegEncContext *s){
int csize= (c->width/2)*(c->height/2);
Picture pre_input, *pre_input_ptr= i ? s->input_picture[i-1] : s->next_picture_ptr;
- if(pre_input_ptr)
- pre_input= *pre_input_ptr;
-
- if(pre_input.type != FF_BUFFER_TYPE_SHARED && i){
- pre_input.data[0]+=INPLACE_OFFSET;
- pre_input.data[1]+=INPLACE_OFFSET;
- pre_input.data[2]+=INPLACE_OFFSET;
- }
-
avcodec_get_frame_defaults(&input[i]);
input[i].data[0]= av_malloc(ysize + 2*csize);
input[i].data[1]= input[i].data[0] + ysize;
@@ -2292,7 +2283,15 @@ static int estimate_best_b_count(MpegEncContext *s){
input[i].linesize[1]=
input[i].linesize[2]= c->width/2;
- if(!i || s->input_picture[i-1]){
+ if(pre_input_ptr && (!i || s->input_picture[i-1])) {
+ pre_input= *pre_input_ptr;
+
+ if(pre_input.type != FF_BUFFER_TYPE_SHARED && i) {
+ pre_input.data[0]+=INPLACE_OFFSET;
+ pre_input.data[1]+=INPLACE_OFFSET;
+ pre_input.data[2]+=INPLACE_OFFSET;
+ }
+
s->dsp.shrink[scale](input[i].data[0], input[i].linesize[0], pre_input.data[0], pre_input.linesize[0], c->width, c->height);
s->dsp.shrink[scale](input[i].data[1], input[i].linesize[1], pre_input.data[1], pre_input.linesize[1], c->width>>1, c->height>>1);
s->dsp.shrink[scale](input[i].data[2], input[i].linesize[2], pre_input.data[2], pre_input.linesize[2], c->width>>1, c->height>>1);
@@ -4651,6 +4650,7 @@ void ff_mpeg_flush(AVCodecContext *avctx){
s->parse_context.index= 0;
s->parse_context.last_index= 0;
s->bitstream_buffer_size=0;
+ s->pp_time=0;
}
#ifdef CONFIG_ENCODERS
@@ -5399,7 +5399,7 @@ static int encode_thread(AVCodecContext *c, void *arg){
if(s->avctx->mb_decision == FF_MB_DECISION_BITS)
MPV_decode_mb(s, s->block);
} else {
- int motion_x, motion_y;
+ int motion_x = 0, motion_y = 0;
s->mv_type=MV_TYPE_16X16;
// only one MB-Type possible
@@ -5425,7 +5425,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->p_field_mv_table[i][j][xy][0];
s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
}
- motion_x = motion_y = 0;
break;
case CANDIDATE_MB_TYPE_INTER4V:
s->mv_dir = MV_DIR_FORWARD;
@@ -5435,7 +5434,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->current_picture.motion_val[0][s->block_index[i]][0];
s->mv[0][i][1] = s->current_picture.motion_val[0][s->block_index[i]][1];
}
- motion_x= motion_y= 0;
break;
case CANDIDATE_MB_TYPE_DIRECT:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
@@ -5455,8 +5453,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
case CANDIDATE_MB_TYPE_BIDIR:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
s->mb_intra= 0;
- motion_x=0;
- motion_y=0;
s->mv[0][0][0] = s->b_bidir_forw_mv_table[xy][0];
s->mv[0][0][1] = s->b_bidir_forw_mv_table[xy][1];
s->mv[1][0][0] = s->b_bidir_back_mv_table[xy][0];
@@ -5484,7 +5480,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[0][i][0] = s->b_field_mv_table[0][i][j][xy][0];
s->mv[0][i][1] = s->b_field_mv_table[0][i][j][xy][1];
}
- motion_x=motion_y=0;
break;
case CANDIDATE_MB_TYPE_BACKWARD_I:
s->mv_dir = MV_DIR_BACKWARD;
@@ -5495,7 +5490,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[1][i][0] = s->b_field_mv_table[1][i][j][xy][0];
s->mv[1][i][1] = s->b_field_mv_table[1][i][j][xy][1];
}
- motion_x=motion_y=0;
break;
case CANDIDATE_MB_TYPE_BIDIR_I:
s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD;
@@ -5508,10 +5502,8 @@ static int encode_thread(AVCodecContext *c, void *arg){
s->mv[dir][i][1] = s->b_field_mv_table[dir][i][j][xy][1];
}
}
- motion_x=motion_y=0;
break;
default:
- motion_x=motion_y=0; //gcc warning fix
av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
}
@@ -6236,7 +6228,7 @@ static int dct_quantize_refine(MpegEncContext *s, //FIXME breaks denoise?
uint8_t * length;
uint8_t * last_length;
int lambda;
- int rle_index, run, q, sum;
+ int rle_index, run, q = 1, sum; //q is only used when s->mb_intra is true
#ifdef REFINE_STATS
static int count=0;
static int after_last=0;
diff --git a/src/libffmpeg/libavcodec/msvideo1.c b/src/libffmpeg/libavcodec/msvideo1.c
index 5929e1c63..1e3f6cce2 100644
--- a/src/libffmpeg/libavcodec/msvideo1.c
+++ b/src/libffmpeg/libavcodec/msvideo1.c
@@ -245,25 +245,25 @@ static void msvideo1_decode_16bit(Msvideo1Context *s)
flags = (byte_b << 8) | byte_a;
CHECK_STREAM_PTR(4);
- colors[0] = LE_16(&s->buf[stream_ptr]);
+ colors[0] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[1] = LE_16(&s->buf[stream_ptr]);
+ colors[1] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
if (colors[0] & 0x8000) {
/* 8-color encoding */
CHECK_STREAM_PTR(12);
- colors[2] = LE_16(&s->buf[stream_ptr]);
+ colors[2] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[3] = LE_16(&s->buf[stream_ptr]);
+ colors[3] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[4] = LE_16(&s->buf[stream_ptr]);
+ colors[4] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[5] = LE_16(&s->buf[stream_ptr]);
+ colors[5] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[6] = LE_16(&s->buf[stream_ptr]);
+ colors[6] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
- colors[7] = LE_16(&s->buf[stream_ptr]);
+ colors[7] = AV_RL16(&s->buf[stream_ptr]);
stream_ptr += 2;
for (pixel_y = 0; pixel_y < 4; pixel_y++) {
diff --git a/src/libffmpeg/libavcodec/nuv.c b/src/libffmpeg/libavcodec/nuv.c
index 592d3de03..19e343056 100644
--- a/src/libffmpeg/libavcodec/nuv.c
+++ b/src/libffmpeg/libavcodec/nuv.c
@@ -64,9 +64,9 @@ static int get_quant(AVCodecContext *avctx, NuvContext *c,
return -1;
}
for (i = 0; i < 64; i++, buf += 4)
- c->lq[i] = LE_32(buf);
+ c->lq[i] = AV_RL32(buf);
for (i = 0; i < 64; i++, buf += 4)
- c->cq[i] = LE_32(buf);
+ c->cq[i] = AV_RL32(buf);
return 0;
}
diff --git a/src/libffmpeg/libavcodec/opt.c b/src/libffmpeg/libavcodec/opt.c
index a200d9a82..70babd587 100644
--- a/src/libffmpeg/libavcodec/opt.c
+++ b/src/libffmpeg/libavcodec/opt.c
@@ -31,9 +31,9 @@
#include "eval.h"
//FIXME order them and do a bin search
-static AVOption *find_opt(void *v, const char *name, const char *unit){
+static const AVOption *find_opt(void *v, const char *name, const char *unit){
AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
- AVOption *o= c->option;
+ const AVOption *o= c->option;
for(;o && o->name; o++){
if(!strcmp(o->name, name) && (!unit || !strcmp(o->unit, unit)) )
@@ -42,14 +42,14 @@ static AVOption *find_opt(void *v, const char *name, const char *unit){
return NULL;
}
-AVOption *av_next_option(void *obj, AVOption *last){
+const AVOption *av_next_option(void *obj, const AVOption *last){
if(last && last[1].name) return ++last;
else if(last) return NULL;
else return (*(AVClass**)obj)->option;
}
-static AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
- AVOption *o= find_opt(obj, name, NULL);
+static const AVOption *av_set_number(void *obj, const char *name, double num, int den, int64_t intnum){
+ const AVOption *o= find_opt(obj, name, NULL);
void *dst;
if(!o || o->offset<=0)
return NULL;
@@ -76,10 +76,10 @@ static AVOption *av_set_number(void *obj, const char *name, double num, int den,
return o;
}
-static AVOption *set_all_opt(void *v, const char *unit, double d){
+static const AVOption *set_all_opt(void *v, const char *unit, double d){
AVClass *c= *(AVClass**)v; //FIXME silly way of storing AVClass
- AVOption *o= c->option;
- AVOption *ret=NULL;
+ const AVOption *o= c->option;
+ const AVOption *ret=NULL;
for(;o && o->name; o++){
if(o->type != FF_OPT_TYPE_CONST && o->unit && !strcmp(o->unit, unit)){
@@ -108,8 +108,8 @@ static const char *const_names[]={
0
};
-AVOption *av_set_string(void *obj, const char *name, const char *val){
- AVOption *o= find_opt(obj, name, NULL);
+const AVOption *av_set_string(void *obj, const char *name, const char *val){
+ const AVOption *o= find_opt(obj, name, NULL);
if(o && o->offset==0 && o->type == FF_OPT_TYPE_CONST && o->unit){
return set_all_opt(obj, o->unit, o->default_val);
}
@@ -133,7 +133,7 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
d = ff_eval2(buf, const_values, const_names, NULL, NULL, NULL, NULL, NULL, &error);
if(isnan(d)) {
- AVOption *o_named= find_opt(obj, buf, o->unit);
+ const AVOption *o_named= find_opt(obj, buf, o->unit);
if(o_named && o_named->type == FF_OPT_TYPE_CONST)
d= o_named->default_val;
else if(!strcmp(buf, "default")) d= o->default_val;
@@ -162,15 +162,15 @@ AVOption *av_set_string(void *obj, const char *name, const char *val){
return o;
}
-AVOption *av_set_double(void *obj, const char *name, double n){
+const AVOption *av_set_double(void *obj, const char *name, double n){
return av_set_number(obj, name, n, 1, 1);
}
-AVOption *av_set_q(void *obj, const char *name, AVRational n){
+const AVOption *av_set_q(void *obj, const char *name, AVRational n){
return av_set_number(obj, name, n.num, n.den, 1);
}
-AVOption *av_set_int(void *obj, const char *name, int64_t n){
+const AVOption *av_set_int(void *obj, const char *name, int64_t n){
return av_set_number(obj, name, 1, 1, n);
}
@@ -179,8 +179,8 @@ AVOption *av_set_int(void *obj, const char *name, int64_t n){
* @param buf a buffer which is used for returning non string values as strings, can be NULL
* @param buf_len allocated length in bytes of buf
*/
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len){
- AVOption *o= find_opt(obj, name, NULL);
+const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len){
+ const AVOption *o= find_opt(obj, name, NULL);
void *dst;
if(!o || o->offset<=0)
return NULL;
@@ -205,8 +205,8 @@ const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *b
return buf;
}
-static int av_get_number(void *obj, const char *name, AVOption **o_out, double *num, int *den, int64_t *intnum){
- AVOption *o= find_opt(obj, name, NULL);
+static int av_get_number(void *obj, const char *name, const AVOption **o_out, double *num, int *den, int64_t *intnum){
+ const AVOption *o= find_opt(obj, name, NULL);
void *dst;
if(!o || o->offset<=0)
goto error;
@@ -230,7 +230,7 @@ error:
return -1;
}
-double av_get_double(void *obj, const char *name, AVOption **o_out){
+double av_get_double(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -239,7 +239,7 @@ double av_get_double(void *obj, const char *name, AVOption **o_out){
return num*intnum/den;
}
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
+AVRational av_get_q(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -251,7 +251,7 @@ AVRational av_get_q(void *obj, const char *name, AVOption **o_out){
return av_d2q(num*intnum/den, 1<<24);
}
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
+int64_t av_get_int(void *obj, const char *name, const AVOption **o_out){
int64_t intnum=1;
double num=1;
int den=1;
@@ -260,9 +260,9 @@ int64_t av_get_int(void *obj, const char *name, AVOption **o_out){
return num*intnum/den;
}
-static void opt_list(void *obj, void *av_log_obj, char *unit)
+static void opt_list(void *obj, void *av_log_obj, const char *unit)
{
- AVOption *opt=NULL;
+ const AVOption *opt=NULL;
while((opt= av_next_option(obj, opt))){
if(!(opt->flags & (AV_OPT_FLAG_ENCODING_PARAM|AV_OPT_FLAG_DECODING_PARAM)))
@@ -345,7 +345,7 @@ int av_opt_show(void *obj, void *av_log_obj){
*/
void av_opt_set_defaults(void *s)
{
- AVOption *opt = NULL;
+ const AVOption *opt = NULL;
while ((opt = av_next_option(s, opt)) != NULL) {
switch(opt->type) {
case FF_OPT_TYPE_CONST:
diff --git a/src/libffmpeg/libavcodec/opt.h b/src/libffmpeg/libavcodec/opt.h
index b8a17031b..ff65456d8 100644
--- a/src/libffmpeg/libavcodec/opt.h
+++ b/src/libffmpeg/libavcodec/opt.h
@@ -68,15 +68,15 @@ typedef struct AVOption {
} AVOption;
-AVOption *av_set_string(void *obj, const char *name, const char *val);
-AVOption *av_set_double(void *obj, const char *name, double n);
-AVOption *av_set_q(void *obj, const char *name, AVRational n);
-AVOption *av_set_int(void *obj, const char *name, int64_t n);
-double av_get_double(void *obj, const char *name, AVOption **o_out);
-AVRational av_get_q(void *obj, const char *name, AVOption **o_out);
-int64_t av_get_int(void *obj, const char *name, AVOption **o_out);
-const char *av_get_string(void *obj, const char *name, AVOption **o_out, char *buf, int buf_len);
-AVOption *av_next_option(void *obj, AVOption *last);
+const AVOption *av_set_string(void *obj, const char *name, const char *val);
+const AVOption *av_set_double(void *obj, const char *name, double n);
+const AVOption *av_set_q(void *obj, const char *name, AVRational n);
+const AVOption *av_set_int(void *obj, const char *name, int64_t n);
+double av_get_double(void *obj, const char *name, const AVOption **o_out);
+AVRational av_get_q(void *obj, const char *name, const AVOption **o_out);
+int64_t av_get_int(void *obj, const char *name, const AVOption **o_out);
+const char *av_get_string(void *obj, const char *name, const AVOption **o_out, char *buf, int buf_len);
+const AVOption *av_next_option(void *obj, const AVOption *last);
int av_opt_show(void *obj, void *av_log_obj);
void av_opt_set_defaults(void *s);
diff --git a/src/libffmpeg/libavcodec/parser.c b/src/libffmpeg/libavcodec/parser.c
index 740ad855c..62a95c1a4 100644
--- a/src/libffmpeg/libavcodec/parser.c
+++ b/src/libffmpeg/libavcodec/parser.c
@@ -632,9 +632,14 @@ static const int ac3_bitrates[64] = {
384, 448, 448, 512, 512, 576, 576, 640, 640,
};
-static const int ac3_channels[8] = {
+static const uint8_t ac3_channels[8] = {
2, 1, 2, 3, 3, 4, 4, 5
};
+
+static const uint8_t eac3_blocks[4] = {
+ 1, 2, 3, 6
+};
+
#endif /* CONFIG_AC3_PARSER */
#ifdef CONFIG_AAC_PARSER
@@ -653,6 +658,7 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
int *bit_rate, int *samples)
{
unsigned int fscod, frmsizecod, acmod, bsid, lfeon;
+ unsigned int strmtyp, substreamid, frmsiz, fscod2, numblkscod;
GetBitContext bits;
init_get_bits(&bits, buf, AC3_HEADER_SIZE * 8);
@@ -660,32 +666,67 @@ static int ac3_sync(const uint8_t *buf, int *channels, int *sample_rate,
if(get_bits(&bits, 16) != 0x0b77)
return 0;
- skip_bits(&bits, 16); /* crc */
- fscod = get_bits(&bits, 2);
- frmsizecod = get_bits(&bits, 6);
+ bsid = show_bits_long(&bits, 29) & 0x1f;
+ if(bsid <= 8) { /* Normal AC-3 */
+ skip_bits(&bits, 16); /* crc */
+ fscod = get_bits(&bits, 2);
+ frmsizecod = get_bits(&bits, 6);
+
+ if(fscod == 3)
+ return 0;
+
+ skip_bits(&bits, 5); /* bsid */
+ skip_bits(&bits, 3); /* bsmod */
+ acmod = get_bits(&bits, 3);
+ if(acmod & 1 && acmod != 1)
+ skip_bits(&bits, 2); /* cmixlev */
+ if(acmod & 4)
+ skip_bits(&bits, 2); /* surmixlev */
+ if(acmod & 2)
+ skip_bits(&bits, 2); /* dsurmod */
+ lfeon = get_bits1(&bits);
+
+ *sample_rate = ac3_sample_rates[fscod];
+ *bit_rate = ac3_bitrates[frmsizecod] * 1000;
+ *channels = ac3_channels[acmod] + lfeon;
+ *samples = 6 * 256;
+
+ return ac3_frame_sizes[frmsizecod][fscod] * 2;
+ } else if (bsid >= 10 && bsid <= 16) { /* Enhanced AC-3 */
+ strmtyp = get_bits(&bits, 2);
+ substreamid = get_bits(&bits, 3);
+
+ if (strmtyp != 0 || substreamid != 0)
+ return 0; /* Currently don't support additional streams */
+
+ frmsiz = get_bits(&bits, 11) + 1;
+ fscod = get_bits(&bits, 2);
+ if (fscod == 3) {
+ fscod2 = get_bits(&bits, 2);
+ numblkscod = 3;
+
+ if(fscod2 == 3)
+ return 0;
+
+ *sample_rate = ac3_sample_rates[fscod2] / 2;
+ } else {
+ numblkscod = get_bits(&bits, 2);
- if(!ac3_sample_rates[fscod])
- return 0;
+ *sample_rate = ac3_sample_rates[fscod];
+ }
- bsid = get_bits(&bits, 5);
- if(bsid > 8)
- return 0;
- skip_bits(&bits, 3); /* bsmod */
- acmod = get_bits(&bits, 3);
- if(acmod & 1 && acmod != 1)
- skip_bits(&bits, 2); /* cmixlev */
- if(acmod & 4)
- skip_bits(&bits, 2); /* surmixlev */
- if(acmod & 2)
- skip_bits(&bits, 2); /* dsurmod */
- lfeon = get_bits1(&bits);
-
- *sample_rate = ac3_sample_rates[fscod];
- *bit_rate = ac3_bitrates[frmsizecod] * 1000;
- *channels = ac3_channels[acmod] + lfeon;
- *samples = 6 * 256;
-
- return ac3_frame_sizes[frmsizecod][fscod] * 2;
+ acmod = get_bits(&bits, 3);
+ lfeon = get_bits1(&bits);
+
+ *samples = eac3_blocks[numblkscod] * 256;
+ *bit_rate = frmsiz * (*sample_rate) * 16 / (*samples);
+ *channels = ac3_channels[acmod] + lfeon;
+
+ return frmsiz * 2;
+ }
+
+ /* Unsupported bitstream version */
+ return 0;
}
#endif /* CONFIG_AC3_PARSER */
diff --git a/src/libffmpeg/libavcodec/pcm.c b/src/libffmpeg/libavcodec/pcm.c
index 26c38b329..4011ed3b5 100644
--- a/src/libffmpeg/libavcodec/pcm.c
+++ b/src/libffmpeg/libavcodec/pcm.c
@@ -410,8 +410,8 @@ static int pcm_decode_frame(AVCodecContext *avctx,
samples = data;
src = buf;
- if(buf_size > AVCODEC_MAX_AUDIO_FRAME_SIZE/2)
- buf_size = AVCODEC_MAX_AUDIO_FRAME_SIZE/2;
+ buf_size= FFMIN(buf_size, *data_size/2);
+ *data_size=0;
switch(avctx->codec->id) {
case CODEC_ID_PCM_S32LE:
diff --git a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
index 6f48893a4..bbc53d761 100644
--- a/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/dsputil_altivec.c
@@ -1107,12 +1107,10 @@ POWERPC_PERF_START_COUNT(altivec_hadamard8_diff8x8_num, 1);
register vector signed short srcV, dstV; \
register vector signed short but0, but1, but2, op1, op2, op3; \
src1 = vec_ld(stride * i, src); \
- if ((((stride * i) + (unsigned long)src) & 0x0000000F) > 8) \
- src2 = vec_ld((stride * i) + 16, src); \
+ src2 = vec_ld((stride * i) + 15, src); \
srcO = vec_perm(src1, src2, vec_lvsl(stride * i, src)); \
dst1 = vec_ld(stride * i, dst); \
- if ((((stride * i) + (unsigned long)dst) & 0x0000000F) > 8) \
- dst2 = vec_ld((stride * i) + 16, dst); \
+ dst2 = vec_ld((stride * i) + 15, dst); \
dstO = vec_perm(dst1, dst2, vec_lvsl(stride * i, dst)); \
/* promote the unsigned chars to signed shorts */ \
/* we're in the 8x8 function, we only care for the first 8 */ \
diff --git a/src/libffmpeg/libavcodec/ppc/float_altivec.c b/src/libffmpeg/libavcodec/ppc/float_altivec.c
index c6e43dec2..22c2de61a 100644
--- a/src/libffmpeg/libavcodec/ppc/float_altivec.c
+++ b/src/libffmpeg/libavcodec/ppc/float_altivec.c
@@ -76,7 +76,6 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
vector unsigned char align = vec_lvsr(0,dst),
mask = vec_lvsl(0, dst);
- t0 = vec_ld(0, dst);
#if 0 //FIXME: there is still something wrong
if (step == 2) {
int y;
@@ -134,6 +133,7 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
#endif
if (step == 1 && src3 == 0)
for (i=0; i<len-3; i+=4) {
+ t0 = vec_ld(0, dst+i);
t1 = vec_ld(15, dst+i);
s0 = vec_ld(0, src0+i);
s1 = vec_ld(0, src1+i);
@@ -144,7 +144,6 @@ static void vector_fmul_add_add_altivec(float *dst, const float *src0,
t0 = vec_perm(edges, d, align);
vec_st(t1, 15, dst+i);
vec_st(t0, 0, dst+i);
- t0 = t1;
}
else
ff_vector_fmul_add_add_c(dst, src0, src1, src2, src3, len, step);
diff --git a/src/libffmpeg/libavcodec/qdm2.c b/src/libffmpeg/libavcodec/qdm2.c
index b9462f3cb..a2630fe7f 100644
--- a/src/libffmpeg/libavcodec/qdm2.c
+++ b/src/libffmpeg/libavcodec/qdm2.c
@@ -1836,7 +1836,7 @@ static int qdm2_decode_init(AVCodecContext *avctx)
extradata += 8;
extradata_size -= 8;
- size = BE_32(extradata);
+ size = AV_RB32(extradata);
if(size > extradata_size){
av_log(avctx, AV_LOG_ERROR, "extradata size too small, %i < %i\n",
@@ -1846,29 +1846,29 @@ static int qdm2_decode_init(AVCodecContext *avctx)
extradata += 4;
av_log(avctx, AV_LOG_DEBUG, "size: %d\n", size);
- if (BE_32(extradata) != MKBETAG('Q','D','C','A')) {
+ if (AV_RB32(extradata) != MKBETAG('Q','D','C','A')) {
av_log(avctx, AV_LOG_ERROR, "invalid extradata, expecting QDCA\n");
return -1;
}
extradata += 8;
- avctx->channels = s->nb_channels = s->channels = BE_32(extradata);
+ avctx->channels = s->nb_channels = s->channels = AV_RB32(extradata);
extradata += 4;
- avctx->sample_rate = BE_32(extradata);
+ avctx->sample_rate = AV_RB32(extradata);
extradata += 4;
- avctx->bit_rate = BE_32(extradata);
+ avctx->bit_rate = AV_RB32(extradata);
extradata += 4;
- s->group_size = BE_32(extradata);
+ s->group_size = AV_RB32(extradata);
extradata += 4;
- s->fft_size = BE_32(extradata);
+ s->fft_size = AV_RB32(extradata);
extradata += 4;
- s->checksum_size = BE_32(extradata);
+ s->checksum_size = AV_RB32(extradata);
extradata += 4;
s->fft_order = av_log2(s->fft_size) + 1;
diff --git a/src/libffmpeg/libavcodec/qdrw.c b/src/libffmpeg/libavcodec/qdrw.c
index 8ebb43c4a..664be2f4f 100644
--- a/src/libffmpeg/libavcodec/qdrw.c
+++ b/src/libffmpeg/libavcodec/qdrw.c
@@ -58,7 +58,7 @@ static int decode_frame(AVCodecContext *avctx,
outdata = a->pic.data[0];
buf += 0x68; /* jump to palette */
- colors = BE_32(buf);
+ colors = AV_RB32(buf);
buf += 4;
if(colors < 0 || colors > 256) {
@@ -68,7 +68,7 @@ static int decode_frame(AVCodecContext *avctx,
for (i = 0; i <= colors; i++) {
unsigned int idx;
- idx = BE_16(buf); /* color index */
+ idx = AV_RB16(buf); /* color index */
buf += 2;
if (idx > 255) {
@@ -93,7 +93,7 @@ static int decode_frame(AVCodecContext *avctx,
/* decode line */
out = outdata;
- size = BE_16(buf); /* size of packed line */
+ size = AV_RB16(buf); /* size of packed line */
buf += 2;
left = size;
next = buf + size;
diff --git a/src/libffmpeg/libavcodec/qtrle.c b/src/libffmpeg/libavcodec/qtrle.c
index d4b314d03..0ccca28c6 100644
--- a/src/libffmpeg/libavcodec/qtrle.c
+++ b/src/libffmpeg/libavcodec/qtrle.c
@@ -96,15 +96,15 @@ static void qtrle_decode_4bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -187,15 +187,15 @@ static void qtrle_decode_8bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -269,15 +269,15 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -299,7 +299,7 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* decode the run length code */
rle_code = -rle_code;
CHECK_STREAM_PTR(2);
- rgb16 = BE_16(&s->buf[stream_ptr]);
+ rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
CHECK_PIXEL_PTR(rle_code * 2);
@@ -314,7 +314,7 @@ static void qtrle_decode_16bpp(QtrleContext *s)
/* copy pixels directly to output */
while (rle_code--) {
- rgb16 = BE_16(&s->buf[stream_ptr]);
+ rgb16 = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
*(unsigned short *)(&rgb[pixel_ptr]) = rgb16;
pixel_ptr += 2;
@@ -347,15 +347,15 @@ static void qtrle_decode_24bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
@@ -427,15 +427,15 @@ static void qtrle_decode_32bpp(QtrleContext *s)
/* fetch the header */
CHECK_STREAM_PTR(2);
- header = BE_16(&s->buf[stream_ptr]);
+ header = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
/* if a header is present, fetch additional decoding parameters */
if (header & 0x0008) {
CHECK_STREAM_PTR(8);
- start_line = BE_16(&s->buf[stream_ptr]);
+ start_line = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
- lines_to_change = BE_16(&s->buf[stream_ptr]);
+ lines_to_change = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 4;
} else {
start_line = 0;
diff --git a/src/libffmpeg/libavcodec/rangecoder.c b/src/libffmpeg/libavcodec/rangecoder.c
index 1f35d0852..fcd564ace 100644
--- a/src/libffmpeg/libavcodec/rangecoder.c
+++ b/src/libffmpeg/libavcodec/rangecoder.c
@@ -66,28 +66,6 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
memset(c->zero_state, 0, sizeof(c->zero_state));
memset(c-> one_state, 0, sizeof(c-> one_state));
-#if 0
- for(i=1; i<256; i++){
- if(c->one_state[i])
- continue;
-
- p= (i*one + 128) >> 8;
- last_p8= i;
- for(;;){
- p+= ((one-p)*factor + one/2) >> 32;
- p8= (256*p + one/2) >> 32; //FIXME try without the one
- if(p8 <= last_p8) p8= last_p8+1;
- if(p8 > max_p) p8= max_p;
- if(p8 < last_p8)
- break;
- c->one_state[last_p8]= p8;
- if(p8 == last_p8)
- break;
- last_p8= p8;
- }
- }
-#endif
-#if 1
last_p8= 0;
p= one/2;
for(i=0; i<128; i++){
@@ -99,7 +77,7 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
p+= ((one-p)*factor + one/2) >> 32;
last_p8= p8;
}
-#endif
+
for(i=256-max_p; i<=max_p; i++){
if(c->one_state[i])
continue;
@@ -114,10 +92,6 @@ void ff_build_rac_states(RangeCoder *c, int factor, int max_p){
for(i=1; i<255; i++)
c->zero_state[i]= 256-c->one_state[256-i];
-#if 0
- for(i=0; i<256; i++)
- av_log(NULL, AV_LOG_DEBUG, "%3d %3d\n", i, c->one_state[i]);
-#endif
}
/**
@@ -155,7 +129,6 @@ int main(){
r[i]= random()%7;
}
-
for(i=0; i<SIZE; i++){
START_TIMER
put_rac(&c, state, r[i]&1);
@@ -177,5 +150,4 @@ STOP_TIMER("get_rac")
return 0;
}
-
#endif
diff --git a/src/libffmpeg/libavcodec/rpza.c b/src/libffmpeg/libavcodec/rpza.c
index 9a996da37..8ab5dbb92 100644
--- a/src/libffmpeg/libavcodec/rpza.c
+++ b/src/libffmpeg/libavcodec/rpza.c
@@ -98,7 +98,7 @@ static void rpza_decode_stream(RpzaContext *s)
s->buf[stream_ptr]);
/* Get chunk size, ingnoring first byte */
- chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
/* If length mismatch use size from MOV file and try to decode anyway */
@@ -140,7 +140,7 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with one color */
case 0xa0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
@@ -157,10 +157,10 @@ static void rpza_decode_stream(RpzaContext *s)
/* Fill blocks with 4 colors */
case 0xc0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
case 0x20:
- colorB = BE_16 (&s->buf[stream_ptr]);
+ colorB = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
/* sort out the colors */
@@ -209,7 +209,7 @@ static void rpza_decode_stream(RpzaContext *s)
for (pixel_x = 0; pixel_x < 4; pixel_x++){
/* We already have color of upper left pixel */
if ((pixel_y != 0) || (pixel_x !=0)) {
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
}
pixels[block_ptr] = colorA;
diff --git a/src/libffmpeg/libavcodec/rv10.c b/src/libffmpeg/libavcodec/rv10.c
index 4b50609c1..af438a34b 100644
--- a/src/libffmpeg/libavcodec/rv10.c
+++ b/src/libffmpeg/libavcodec/rv10.c
@@ -535,7 +535,7 @@ static int rv10_decode_init(AVCodecContext *avctx)
s->height = avctx->height;
s->h263_long_vectors= ((uint8_t*)avctx->extradata)[3] & 1;
- avctx->sub_id= BE_32((uint8_t*)avctx->extradata + 4);
+ avctx->sub_id= AV_RB32((uint8_t*)avctx->extradata + 4);
switch(avctx->sub_id){
case 0x10000000:
diff --git a/src/libffmpeg/libavcodec/smacker.c b/src/libffmpeg/libavcodec/smacker.c
index 2e1784075..0bdbc7977 100644
--- a/src/libffmpeg/libavcodec/smacker.c
+++ b/src/libffmpeg/libavcodec/smacker.c
@@ -277,10 +277,10 @@ static int decode_header_trees(SmackVContext *smk) {
GetBitContext gb;
int mmap_size, mclr_size, full_size, type_size;
- mmap_size = LE_32(smk->avctx->extradata);
- mclr_size = LE_32(smk->avctx->extradata + 4);
- full_size = LE_32(smk->avctx->extradata + 8);
- type_size = LE_32(smk->avctx->extradata + 12);
+ mmap_size = AV_RL32(smk->avctx->extradata);
+ mclr_size = AV_RL32(smk->avctx->extradata + 4);
+ full_size = AV_RL32(smk->avctx->extradata + 8);
+ type_size = AV_RL32(smk->avctx->extradata + 12);
init_get_bits(&gb, smk->avctx->extradata + 16, (smk->avctx->extradata_size - 16) * 8);
@@ -584,7 +584,7 @@ static int smka_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
int bits, stereo;
int pred[2] = {0, 0};
- unp_size = LE_32(buf);
+ unp_size = AV_RL32(buf);
init_get_bits(&gb, buf + 4, (buf_size - 4) * 8);
diff --git a/src/libffmpeg/libavcodec/smc.c b/src/libffmpeg/libavcodec/smc.c
index 77fae328b..349e5f81c 100644
--- a/src/libffmpeg/libavcodec/smc.c
+++ b/src/libffmpeg/libavcodec/smc.c
@@ -120,7 +120,7 @@ static void smc_decode_stream(SmcContext *s)
s->avctx->palctrl->palette_changed = 0;
}
- chunk_size = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
if (chunk_size != s->size)
av_log(s->avctx, AV_LOG_INFO, "warning: MOV chunk size != encoded chunk size (%d != %d); using MOV chunk size\n",
@@ -278,7 +278,7 @@ static void smc_decode_stream(SmcContext *s)
color_table_index = CPAIR * s->buf[stream_ptr++];
while (n_blocks--) {
- color_flags = BE_16(&s->buf[stream_ptr]);
+ color_flags = AV_RB16(&s->buf[stream_ptr]);
stream_ptr += 2;
flag_mask = 0x8000;
block_ptr = row_ptr + pixel_ptr;
@@ -321,7 +321,7 @@ static void smc_decode_stream(SmcContext *s)
color_table_index = CQUAD * s->buf[stream_ptr++];
while (n_blocks--) {
- color_flags = BE_32(&s->buf[stream_ptr]);
+ color_flags = AV_RB32(&s->buf[stream_ptr]);
stream_ptr += 4;
/* flag mask actually acts as a bit shift count here */
flag_mask = 30;
diff --git a/src/libffmpeg/libavcodec/snow.c b/src/libffmpeg/libavcodec/snow.c
index aec0375f6..03e634bf1 100644
--- a/src/libffmpeg/libavcodec/snow.c
+++ b/src/libffmpeg/libavcodec/snow.c
@@ -1961,18 +1961,18 @@ static inline void init_ref(MotionEstContext *c, uint8_t *src[3], uint8_t *ref[3
}
static inline void pred_mv(SnowContext *s, int *mx, int *my, int ref,
- BlockNode *left, BlockNode *top, BlockNode *tr){
+ const BlockNode *left, const BlockNode *top, const BlockNode *tr){
if(s->ref_frames == 1){
*mx = mid_pred(left->mx, top->mx, tr->mx);
*my = mid_pred(left->my, top->my, tr->my);
}else{
const int *scale = scale_mv_ref[ref];
- *mx = mid_pred(left->mx * scale[left->ref] + 128 >>8,
- top ->mx * scale[top ->ref] + 128 >>8,
- tr ->mx * scale[tr ->ref] + 128 >>8);
- *my = mid_pred(left->my * scale[left->ref] + 128 >>8,
- top ->my * scale[top ->ref] + 128 >>8,
- tr ->my * scale[tr ->ref] + 128 >>8);
+ *mx = mid_pred((left->mx * scale[left->ref] + 128) >>8,
+ (top ->mx * scale[top ->ref] + 128) >>8,
+ (tr ->mx * scale[tr ->ref] + 128) >>8);
+ *my = mid_pred((left->my * scale[left->ref] + 128) >>8,
+ (top ->my * scale[top ->ref] + 128) >>8,
+ (tr ->my * scale[tr ->ref] + 128) >>8);
}
}
@@ -2001,12 +2001,12 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
const int block_w= 1<<(LOG2_MB_SIZE - level);
int trx= (x+1)<<rem_depth;
int try= (y+1)<<rem_depth;
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *right = trx<w ? &s->block[index+1] : &null_block;
- BlockNode *bottom= try<h ? &s->block[index+w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *right = trx<w ? &s->block[index+1] : &null_block;
+ const BlockNode *bottom= try<h ? &s->block[index+w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int pl = left->color[0];
int pcb= left->color[1];
int pcr= left->color[2];
@@ -2054,10 +2054,10 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
s->m.mb_stride=2;
s->m.mb_x=
s->m.mb_y= 0;
- s->m.me.skip= 0;
+ c->skip= 0;
- assert(s->m.me. stride == stride);
- assert(s->m.me.uvstride == uvstride);
+ assert(c-> stride == stride);
+ assert(c->uvstride == uvstride);
c->penalty_factor = get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_cmp);
c->sub_penalty_factor= get_penalty_factor(s->lambda, s->lambda2, c->avctx->me_sub_cmp);
@@ -2101,7 +2101,7 @@ static int encode_q_branch(SnowContext *s, int level, int x, int y){
assert(ref_my >= c->ymin);
assert(ref_my <= c->ymax);
- ref_score= s->m.me.sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w);
+ ref_score= c->sub_motion_search(&s->m, &ref_mx, &ref_my, ref_score, 0, 0, level-LOG2_MB_SIZE+4, block_w);
ref_score= ff_get_mb_score(&s->m, ref_mx, ref_my, 0, 0, level-LOG2_MB_SIZE+4, block_w, 0);
ref_score+= 2*av_log2(2*ref)*c->penalty_factor;
if(s->ref_mvs[ref]){
@@ -2229,10 +2229,10 @@ static void encode_q_branch2(SnowContext *s, int level, int x, int y){
const int index= (x + y*w) << rem_depth;
int trx= (x+1)<<rem_depth;
BlockNode *b= &s->block[index];
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int pl = left->color[0];
int pcb= left->color[1];
int pcr= left->color[2];
@@ -2282,10 +2282,10 @@ static void decode_q_branch(SnowContext *s, int level, int x, int y){
const int rem_depth= s->block_max_depth - level;
const int index= (x + y*w) << rem_depth;
int trx= (x+1)<<rem_depth;
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-w] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-w-1] : left;
- BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-w] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-w-1] : left;
+ const BlockNode *tr = y && trx<w && ((x&1)==0 || level==0) ? &s->block[index-w+(1<<rem_depth)] : tl; //FIXME use lt
int s_context= 2*left->level + 2*top->level + tl->level + tr->level;
if(s->keyframe){
@@ -2911,11 +2911,11 @@ static inline int get_block_bits(SnowContext *s, int x, int y, int w){
const int b_stride = s->b_width << s->block_max_depth;
const int b_height = s->b_height<< s->block_max_depth;
int index= x + y*b_stride;
- BlockNode *b = &s->block[index];
- BlockNode *left = x ? &s->block[index-1] : &null_block;
- BlockNode *top = y ? &s->block[index-b_stride] : &null_block;
- BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left;
- BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl;
+ const BlockNode *b = &s->block[index];
+ const BlockNode *left = x ? &s->block[index-1] : &null_block;
+ const BlockNode *top = y ? &s->block[index-b_stride] : &null_block;
+ const BlockNode *tl = y && x ? &s->block[index-b_stride-1] : left;
+ const BlockNode *tr = y && x+w<b_stride ? &s->block[index-b_stride+w] : tl;
int dmx, dmy;
// int mx_context= av_log2(2*FFABS(left->mx - top->mx));
// int my_context= av_log2(2*FFABS(left->my - top->my));
@@ -3555,7 +3555,7 @@ static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand
// START_TIMER
- DWTELEM * line;
+ DWTELEM * line=0; // silence silly "could be used without having been initialized" warning
DWTELEM * prev;
if (start_y != 0)
diff --git a/src/libffmpeg/libavcodec/svq3.c b/src/libffmpeg/libavcodec/svq3.c
index edf3b6714..e02981e61 100644
--- a/src/libffmpeg/libavcodec/svq3.c
+++ b/src/libffmpeg/libavcodec/svq3.c
@@ -826,11 +826,11 @@ static int svq3_decode_frame (AVCodecContext *avctx,
}
/* if a match was found, parse the extra data */
- if (!memcmp (extradata, "SEQH", 4)) {
+ if (extradata && !memcmp (extradata, "SEQH", 4)) {
GetBitContext gb;
- size = BE_32(&extradata[4]);
+ size = AV_RB32(&extradata[4]);
init_get_bits (&gb, extradata + 8, size*8);
/* 'frame size code' and optional 'width, height' */
@@ -910,7 +910,8 @@ static int svq3_decode_frame (AVCodecContext *avctx,
s->next_p_frame_damaged = 0;
}
- frame_start (h);
+ if (frame_start (h) < 0)
+ return -1;
if (s->pict_type == B_TYPE) {
h->frame_num_offset = (h->slice_num - h->prev_frame_num);
diff --git a/src/libffmpeg/libavcodec/truemotion1.c b/src/libffmpeg/libavcodec/truemotion1.c
index 11d9320c0..4b7aa976d 100644
--- a/src/libffmpeg/libavcodec/truemotion1.c
+++ b/src/libffmpeg/libavcodec/truemotion1.c
@@ -348,9 +348,9 @@ static int truemotion1_decode_header(TrueMotion1Context *s)
header.compression = header_buffer[0];
header.deltaset = header_buffer[1];
header.vectable = header_buffer[2];
- header.ysize = LE_16(&header_buffer[3]);
- header.xsize = LE_16(&header_buffer[5]);
- header.checksum = LE_16(&header_buffer[7]);
+ header.ysize = AV_RL16(&header_buffer[3]);
+ header.xsize = AV_RL16(&header_buffer[5]);
+ header.checksum = AV_RL16(&header_buffer[7]);
header.version = header_buffer[9];
header.header_type = header_buffer[10];
header.flags = header_buffer[11];
diff --git a/src/libffmpeg/libavcodec/truemotion2.c b/src/libffmpeg/libavcodec/truemotion2.c
index 1b67bd22a..e9bc6b7cb 100644
--- a/src/libffmpeg/libavcodec/truemotion2.c
+++ b/src/libffmpeg/libavcodec/truemotion2.c
@@ -208,7 +208,7 @@ static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf)
obuf = buf;
- magic = LE_32(buf);
+ magic = AV_RL32(buf);
buf += 4;
if(magic == 0x00000100) { /* old header */
@@ -217,7 +217,7 @@ static inline int tm2_read_header(TM2Context *ctx, uint8_t *buf)
} else if(magic == 0x00000101) { /* new header */
int w, h, size, flags, xr, yr;
- length = LE_32(buf);
+ length = AV_RL32(buf);
buf += 4;
init_get_bits(&ctx->gb, buf, 32 * 8);
@@ -270,17 +270,17 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
TM2Codes codes;
/* get stream length in dwords */
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
skip = len * 4 + 4;
if(len == 0)
return 4;
- toks = BE_32(buf); buf += 4; cur += 4;
+ toks = AV_RB32(buf); buf += 4; cur += 4;
if(toks & 1) {
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
if(len == TM2_ESCAPE) {
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
}
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
@@ -291,7 +291,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
}
}
/* skip unused fields */
- if(BE_32(buf) == TM2_ESCAPE) {
+ if(AV_RB32(buf) == TM2_ESCAPE) {
buf += 4; cur += 4; /* some unknown length - could be escaped too */
}
buf += 4; cur += 4;
@@ -312,7 +312,7 @@ static int tm2_read_stream(TM2Context *ctx, uint8_t *buf, int stream_id) {
}
ctx->tokens[stream_id] = av_realloc(ctx->tokens[stream_id], toks * sizeof(int));
ctx->tok_lens[stream_id] = toks;
- len = BE_32(buf); buf += 4; cur += 4;
+ len = AV_RB32(buf); buf += 4; cur += 4;
if(len > 0) {
init_get_bits(&ctx->gb, buf, (skip - cur) * 8);
for(i = 0; i < toks; i++)
diff --git a/src/libffmpeg/libavcodec/truespeech.c b/src/libffmpeg/libavcodec/truespeech.c
index 077e9b037..d37aa9454 100644
--- a/src/libffmpeg/libavcodec/truespeech.c
+++ b/src/libffmpeg/libavcodec/truespeech.c
@@ -62,7 +62,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
uint32_t t;
/* first dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->flag = t & 1;
@@ -77,7 +77,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->vector[7] = ts_codebook[7][(t >> 29) & 0x7];
/* second dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->offset2[0] = (t >> 0) & 0x7F;
@@ -88,7 +88,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] = ((t >> 28) & 0xF) << 4;
/* third dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulseval[0] = (t >> 0) & 0x3FFF;
@@ -97,7 +97,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[1] = (t >> 28) & 0x0F;
/* fourth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulseval[2] = (t >> 0) & 0x3FFF;
@@ -106,7 +106,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[1] |= ((t >> 28) & 0x0F) << 4;
/* fifth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[0] = (t >> 4) & 0x7FFFFFF;
@@ -116,7 +116,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= (t >> 31) & 1;
/* sixth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[1] = (t >> 4) & 0x7FFFFFF;
@@ -126,7 +126,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= ((t >> 31) & 1) << 1;
/* seventh dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[2] = (t >> 4) & 0x7FFFFFF;
@@ -136,7 +136,7 @@ static void truespeech_read_frame(TSContext *dec, uint8_t *input)
dec->offset1[0] |= ((t >> 31) & 1) << 2;
/* eighth dword */
- t = LE_32(input);
+ t = AV_RL32(input);
input += 4;
dec->pulsepos[3] = (t >> 4) & 0x7FFFFFF;
diff --git a/src/libffmpeg/libavcodec/tscc.c b/src/libffmpeg/libavcodec/tscc.c
index a24540f37..e379abbbf 100644
--- a/src/libffmpeg/libavcodec/tscc.c
+++ b/src/libffmpeg/libavcodec/tscc.c
@@ -121,14 +121,14 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
}
} else if (c->bpp == 16) {
for(i = 0; i < p2; i++) {
- pix16 = LE_16(src);
+ pix16 = AV_RL16(src);
src += 2;
*(uint16_t*)output = pix16;
output += 2;
}
} else if (c->bpp == 32) {
for(i = 0; i < p2; i++) {
- pix32 = LE_32(src);
+ pix32 = AV_RL32(src);
src += 4;
*(uint32_t*)output = pix32;
output += 4;
@@ -140,7 +140,7 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
switch(c->bpp){
case 8: pix[0] = *src++;
break;
- case 16: pix16 = LE_16(src);
+ case 16: pix16 = AV_RL16(src);
src += 2;
*(uint16_t*)pix = pix16;
break;
@@ -148,7 +148,7 @@ static int decode_rle(CamtasiaContext *c, unsigned int srcsize)
pix[1] = *src++;
pix[2] = *src++;
break;
- case 32: pix32 = LE_32(src);
+ case 32: pix32 = AV_RL32(src);
src += 4;
*(uint32_t*)pix = pix32;
break;
diff --git a/src/libffmpeg/libavcodec/utils.c b/src/libffmpeg/libavcodec/utils.c
index 36dcc7746..f6f061360 100644
--- a/src/libffmpeg/libavcodec/utils.c
+++ b/src/libffmpeg/libavcodec/utils.c
@@ -512,14 +512,14 @@ static const AVOption options[]={
{"ms", "workaround various bugs in microsofts broken decoders", 0, FF_OPT_TYPE_CONST, FF_BUG_MS, INT_MIN, INT_MAX, V|D, "bug"},
{"lelim", "single coefficient elimination threshold for luminance (negative values also consider dc coefficient)", OFFSET(luma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
{"celim", "single coefficient elimination threshold for chrominance (negative values also consider dc coefficient)", OFFSET(chroma_elim_threshold), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E},
-{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, V|E, "strict"},
+{"strict", "how strictly to follow the standards", OFFSET(strict_std_compliance), FF_OPT_TYPE_INT, DEFAULT, INT_MIN, INT_MAX, A|V|D, "strict"},
{"very", "strictly conform to a older more strict version of the spec or reference software", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_VERY_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
{"strict", "strictly conform to all the things in the spec no matter what consequences", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_STRICT, INT_MIN, INT_MAX, V|E, "strict"},
{"normal", NULL, 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_NORMAL, INT_MIN, INT_MAX, V|E, "strict"},
{"inofficial", "allow inofficial extensions", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_INOFFICIAL, INT_MIN, INT_MAX, V|E, "strict"},
{"experimental", "allow non standarized experimental things", 0, FF_OPT_TYPE_CONST, FF_COMPLIANCE_EXPERIMENTAL, INT_MIN, INT_MAX, V|E, "strict"},
{"b_qoffset", "qp offset between p and b frames", OFFSET(b_quant_offset), FF_OPT_TYPE_FLOAT, 1.25, FLT_MIN, FLT_MAX, V|E},
-{"er", "set error resilience strategy", OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
+{"er", "set error resilience strategy", OFFSET(error_resilience), FF_OPT_TYPE_INT, FF_ER_CAREFUL, INT_MIN, INT_MAX, A|V|D, "er"},
{"careful", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_CAREFUL, INT_MIN, INT_MAX, V|D, "er"},
{"compliant", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_COMPLIANT, INT_MIN, INT_MAX, V|D, "er"},
{"aggressive", NULL, 0, FF_OPT_TYPE_CONST, FF_ER_AGGRESSIVE, INT_MIN, INT_MAX, V|D, "er"},
@@ -918,22 +918,44 @@ int avcodec_decode_video(AVCodecContext *avctx, AVFrame *picture,
*number of bytes used. If no frame could be decompressed,
*frame_size_ptr is zero. Otherwise, it is the decompressed frame
*size in BYTES. */
-int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+int avcodec_decode_audio2(AVCodecContext *avctx, int16_t *samples,
int *frame_size_ptr,
uint8_t *buf, int buf_size)
{
int ret;
- *frame_size_ptr= 0;
+ //FIXME remove the check below _after_ ensuring that all audio check that the available space is enough
+ if(*frame_size_ptr < AVCODEC_MAX_AUDIO_FRAME_SIZE){
+ av_log(avctx, AV_LOG_ERROR, "buffer smaller then AVCODEC_MAX_AUDIO_FRAME_SIZE\n");
+ return -1;
+ }
+ if(*frame_size_ptr < FF_MIN_BUFFER_SIZE ||
+ *frame_size_ptr < avctx->channels * avctx->frame_size * sizeof(int16_t) ||
+ *frame_size_ptr < buf_size){
+ av_log(avctx, AV_LOG_ERROR, "buffer too small\n");
+ return -1;
+ }
if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
ret = avctx->codec->decode(avctx, samples, frame_size_ptr,
buf, buf_size);
avctx->frame_number++;
- }else
+ }else{
ret= 0;
+ *frame_size_ptr=0;
+ }
return ret;
}
+#if LIBAVCODEC_VERSION_INT < ((52<<16)+(0<<8)+0)
+int avcodec_decode_audio(AVCodecContext *avctx, int16_t *samples,
+ int *frame_size_ptr,
+ uint8_t *buf, int buf_size){
+ *frame_size_ptr= AVCODEC_MAX_AUDIO_FRAME_SIZE;
+ return avcodec_decode_audio2(avctx, samples, frame_size_ptr, buf, buf_size);
+}
+#endif
+
+
/* decode a subtitle message. return -1 if error, otherwise return the
*number of bytes used. If no subtitle could be decompressed,
*got_sub_ptr is zero. Otherwise, the subtitle is stored in *sub. */
diff --git a/src/libffmpeg/libavcodec/vc1.c b/src/libffmpeg/libavcodec/vc1.c
index 231f3ca26..40b79b326 100644
--- a/src/libffmpeg/libavcodec/vc1.c
+++ b/src/libffmpeg/libavcodec/vc1.c
@@ -1268,9 +1268,23 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
v->s.avctx->coded_height = (get_bits(gb, 12) + 1) << 1;
v->broadcast = get_bits1(gb);
v->interlace = get_bits1(gb);
+ if(v->interlace){
+ av_log(v->s.avctx, AV_LOG_ERROR, "Interlaced mode not supported (yet)\n");
+ return -1;
+ }
v->tfcntrflag = get_bits1(gb);
v->finterpflag = get_bits1(gb);
get_bits1(gb); // reserved
+
+ av_log(v->s.avctx, AV_LOG_DEBUG,
+ "Advanced Profile level %i:\nfrmrtq_postproc=%i, bitrtq_postproc=%i\n"
+ "LoopFilter=%i, ChromaFormat=%i, Pulldown=%i, Interlace: %i\n"
+ "TFCTRflag=%i, FINTERPflag=%i\n",
+ v->level, v->frmrtq_postproc, v->bitrtq_postproc,
+ v->s.loop_filter, v->chromaformat, v->broadcast, v->interlace,
+ v->tfcntrflag, v->finterpflag
+ );
+
v->psf = get_bits1(gb);
if(v->psf) { //PsF, 6.1.13
av_log(v->s.avctx, AV_LOG_ERROR, "Progressive Segmented Frame mode: not supported (yet)\n");
@@ -1279,15 +1293,17 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
if(get_bits1(gb)) { //Display Info - decoding is not affected by it
int w, h, ar = 0;
av_log(v->s.avctx, AV_LOG_INFO, "Display extended info:\n");
- w = get_bits(gb, 14);
- h = get_bits(gb, 14);
+ w = get_bits(gb, 14) + 1;
+ h = get_bits(gb, 14) + 1;
av_log(v->s.avctx, AV_LOG_INFO, "Display dimensions: %ix%i\n", w, h);
- //TODO: store aspect ratio in AVCodecContext
if(get_bits1(gb))
ar = get_bits(gb, 4);
- if(ar == 15) {
+ if(ar && ar < 14){
+ v->s.avctx->sample_aspect_ratio = vc1_pixel_aspect[ar];
+ }else if(ar == 15){
w = get_bits(gb, 8);
h = get_bits(gb, 8);
+ v->s.avctx->sample_aspect_ratio = (AVRational){w, h};
}
if(get_bits1(gb)){ //framerate stuff
@@ -1323,13 +1339,13 @@ static int decode_sequence_header_adv(VC1Context *v, GetBitContext *gb)
static int decode_entry_point(AVCodecContext *avctx, GetBitContext *gb)
{
VC1Context *v = avctx->priv_data;
- int i;
+ int i, blink, refdist;
av_log(avctx, AV_LOG_DEBUG, "Entry point: %08X\n", show_bits_long(gb, 32));
- get_bits1(gb); // broken link
+ blink = get_bits1(gb); // broken link
avctx->max_b_frames = 1 - get_bits1(gb); // 'closed entry' also signalize possible B-frames
v->panscanflag = get_bits1(gb);
- get_bits1(gb); // refdist flag
+ refdist = get_bits1(gb); // refdist flag
v->s.loop_filter = get_bits1(gb);
v->fastuvmc = get_bits1(gb);
v->extended_mv = get_bits1(gb);
@@ -1359,6 +1375,13 @@ static int decode_entry_point(AVCodecContext *avctx, GetBitContext *gb)
skip_bits(gb, 3); // UV range, ignored for now
}
+ av_log(avctx, AV_LOG_DEBUG, "Entry point info:\n"
+ "BrokenLink=%i, ClosedEntry=%i, PanscanFlag=%i\n"
+ "RefDist=%i, Postproc=%i, FastUVMC=%i, ExtMV=%i\n"
+ "DQuant=%i, VSTransform=%i, Overlap=%i, Qmode=%i\n",
+ blink, 1 - avctx->max_b_frames, v->panscanflag, refdist, v->s.loop_filter,
+ v->fastuvmc, v->extended_mv, v->dquant, v->vstransform, v->overlap, v->quantizer_mode);
+
return 0;
}
@@ -4128,7 +4151,7 @@ static int vc1_decode_init(AVCodecContext *avctx)
}
while(edata_size > 8) {
// test if we've found header
- if(BE_32(edata) == 0x0000010F) {
+ if(AV_RB32(edata) == 0x0000010F) {
edata += 4;
edata_size -= 4;
break;
@@ -4144,7 +4167,7 @@ static int vc1_decode_init(AVCodecContext *avctx)
while(edata_size > 8) {
// test if we've found entry point
- if(BE_32(edata) == 0x0000010E) {
+ if(AV_RB32(edata) == 0x0000010E) {
edata += 4;
edata_size -= 4;
break;
diff --git a/src/libffmpeg/libavcodec/vmdav.c b/src/libffmpeg/libavcodec/vmdav.c
index a9937144e..e0f958cbe 100644
--- a/src/libffmpeg/libavcodec/vmdav.c
+++ b/src/libffmpeg/libavcodec/vmdav.c
@@ -92,10 +92,10 @@ static void lz_unpack(unsigned char *src, unsigned char *dest, int dest_len)
s = src;
d = dest;
d_end = d + dest_len;
- dataleft = LE_32(s);
+ dataleft = AV_RL32(s);
s += 4;
memset(queue, 0x20, QUEUE_SIZE);
- if (LE_32(s) == 0x56781234) {
+ if (AV_RL32(s) == 0x56781234) {
s += 4;
qpos = 0x111;
speclen = 0xF + 3;
@@ -204,10 +204,10 @@ static void vmd_decode(VmdVideoContext *s)
int frame_width, frame_height;
int dp_size;
- frame_x = LE_16(&s->buf[6]);
- frame_y = LE_16(&s->buf[8]);
- frame_width = LE_16(&s->buf[10]) - frame_x + 1;
- frame_height = LE_16(&s->buf[12]) - frame_y + 1;
+ frame_x = AV_RL16(&s->buf[6]);
+ frame_y = AV_RL16(&s->buf[8]);
+ frame_width = AV_RL16(&s->buf[10]) - frame_x + 1;
+ frame_height = AV_RL16(&s->buf[12]) - frame_y + 1;
/* if only a certain region will be updated, copy the entire previous
* frame before the decode */
@@ -339,7 +339,7 @@ static int vmdvideo_decode_init(AVCodecContext *avctx)
}
vmd_header = (unsigned char *)avctx->extradata;
- s->unpack_buffer_size = LE_32(&vmd_header[800]);
+ s->unpack_buffer_size = AV_RL32(&vmd_header[800]);
s->unpack_buffer = av_malloc(s->unpack_buffer_size);
if (!s->unpack_buffer)
return -1;
diff --git a/src/libffmpeg/libavcodec/vp3.c b/src/libffmpeg/libavcodec/vp3.c
index 6a398693a..f02215407 100644
--- a/src/libffmpeg/libavcodec/vp3.c
+++ b/src/libffmpeg/libavcodec/vp3.c
@@ -2643,7 +2643,6 @@ AVCodec vp3_decoder = {
NULL
};
-#ifndef CONFIG_LIBTHEORA
AVCodec theora_decoder = {
"theora",
CODEC_TYPE_VIDEO,
@@ -2656,4 +2655,3 @@ AVCodec theora_decoder = {
0,
NULL
};
-#endif
diff --git a/src/libffmpeg/libavcodec/vp56.h b/src/libffmpeg/libavcodec/vp56.h
index f8b3a8e4b..50e201550 100644
--- a/src/libffmpeg/libavcodec/vp56.h
+++ b/src/libffmpeg/libavcodec/vp56.h
@@ -76,6 +76,8 @@ struct vp56_context {
uint8_t *edge_emu_buffer_alloc;
uint8_t *edge_emu_buffer;
vp56_range_coder_t c;
+ vp56_range_coder_t cc;
+ vp56_range_coder_t *ccp;
int sub_version;
/* frame info */
@@ -108,6 +110,7 @@ struct vp56_context {
int vector_candidate_pos;
/* filtering hints */
+ int filter_header; /* used in vp6 only */
int deblock_filtering;
int filter_selection;
int filter_mode;
diff --git a/src/libffmpeg/libavcodec/vp6.c b/src/libffmpeg/libavcodec/vp6.c
index 381fcc8ee..df4ebf87d 100644
--- a/src/libffmpeg/libavcodec/vp6.c
+++ b/src/libffmpeg/libavcodec/vp6.c
@@ -43,13 +43,12 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
{
vp56_range_coder_t *c = &s->c;
int parse_filter_info = 0;
+ int coeff_offset = 0;
int vrt_shift = 0;
int sub_version;
int rows, cols;
int res = 1;
-
- if (buf[0] & 1)
- return 0;
+ int separated_coeff = buf[0] & 1;
s->frames[VP56_FRAME_CURRENT].key_frame = !(buf[0] & 0x80);
vp56_init_dequant(s, (buf[0] >> 1) & 0x3F);
@@ -58,12 +57,16 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
sub_version = buf[1] >> 3;
if (sub_version > 8)
return 0;
- if ((buf[1] & 0x06) != 0x06)
- return 0;
+ s->filter_header = buf[1] & 0x06;
if (buf[1] & 1) {
av_log(s->avctx, AV_LOG_ERROR, "interlacing not supported\n");
return 0;
}
+ if (separated_coeff || !s->filter_header) {
+ coeff_offset = AV_RB16(buf+2) - 2;
+ buf += 2;
+ buf_size -= 2;
+ }
rows = buf[2]; /* number of stored macroblock rows */
cols = buf[3]; /* number of stored macroblock cols */
@@ -83,7 +86,7 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
vp56_init_range_decoder(c, buf+6, buf_size-6);
vp56_rac_gets(c, 2);
- parse_filter_info = 1;
+ parse_filter_info = s->filter_header;
if (sub_version < 8)
vrt_shift = 5;
s->sub_version = sub_version;
@@ -91,14 +94,21 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
if (!s->sub_version)
return 0;
+ if (separated_coeff || !s->filter_header) {
+ coeff_offset = AV_RB16(buf+1) - 2;
+ buf += 2;
+ buf_size -= 2;
+ }
vp56_init_range_decoder(c, buf+1, buf_size-1);
*golden_frame = vp56_rac_get(c);
- s->deblock_filtering = vp56_rac_get(c);
- if (s->deblock_filtering)
- vp56_rac_get(c);
- if (s->sub_version > 7)
- parse_filter_info = vp56_rac_get(c);
+ if (s->filter_header) {
+ s->deblock_filtering = vp56_rac_get(c);
+ if (s->deblock_filtering)
+ vp56_rac_get(c);
+ if (s->sub_version > 7)
+ parse_filter_info = vp56_rac_get(c);
+ }
}
if (parse_filter_info) {
@@ -118,6 +128,15 @@ static int vp6_parse_header(vp56_context_t *s, uint8_t *buf, int buf_size,
}
vp56_rac_get(c);
+
+ if (coeff_offset) {
+ vp56_init_range_decoder(&s->cc, buf+coeff_offset,
+ buf_size-coeff_offset);
+ s->ccp = &s->cc;
+ } else {
+ s->ccp = &s->c;
+ }
+
return res;
}
@@ -259,7 +278,7 @@ static void vp6_parse_vector_adjustment(vp56_context_t *s, vp56_mv_t *vect)
static void vp6_parse_coeff(vp56_context_t *s)
{
- vp56_range_coder_t *c = &s->c;
+ vp56_range_coder_t *c = s->ccp;
uint8_t *permute = s->scantable.permutated;
uint8_t *model, *model2, *model3;
int coeff, sign, coeff_idx;
diff --git a/src/libffmpeg/libavcodec/vqavideo.c b/src/libffmpeg/libavcodec/vqavideo.c
index 912ced0df..57fe6cf44 100644
--- a/src/libffmpeg/libavcodec/vqavideo.c
+++ b/src/libffmpeg/libavcodec/vqavideo.c
@@ -151,8 +151,8 @@ static int vqa_decode_init(AVCodecContext *avctx)
/* load up the VQA parameters from the header */
vqa_header = (unsigned char *)s->avctx->extradata;
s->vqa_version = vqa_header[0];
- s->width = LE_16(&vqa_header[6]);
- s->height = LE_16(&vqa_header[8]);
+ s->width = AV_RL16(&vqa_header[6]);
+ s->height = AV_RL16(&vqa_header[8]);
if(avcodec_check_dimensions(avctx, s->width, s->height)){
s->width= s->height= 0;
return -1;
@@ -232,9 +232,9 @@ static void decode_format80(unsigned char *src, int src_size,
if (src[src_index] == 0xFF) {
src_index++;
- count = LE_16(&src[src_index]);
+ count = AV_RL16(&src[src_index]);
src_index += 2;
- src_pos = LE_16(&src[src_index]);
+ src_pos = AV_RL16(&src[src_index]);
src_index += 2;
vqa_debug("(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
@@ -245,7 +245,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else if (src[src_index] == 0xFE) {
src_index++;
- count = LE_16(&src[src_index]);
+ count = AV_RL16(&src[src_index]);
src_index += 2;
color = src[src_index++];
vqa_debug("(2) set %X bytes to %02X\n", count, color);
@@ -256,7 +256,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else if ((src[src_index] & 0xC0) == 0xC0) {
count = (src[src_index++] & 0x3F) + 3;
- src_pos = LE_16(&src[src_index]);
+ src_pos = AV_RL16(&src[src_index]);
src_index += 2;
vqa_debug("(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
@@ -276,7 +276,7 @@ static void decode_format80(unsigned char *src, int src_size,
} else {
count = ((src[src_index] & 0x70) >> 4) + 3;
- src_pos = BE_16(&src[src_index]) & 0x0FFF;
+ src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2;
vqa_debug("(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
@@ -326,8 +326,8 @@ static void vqa_decode_chunk(VqaContext *s)
/* first, traverse through the frame and find the subchunks */
while (index < s->size) {
- chunk_type = BE_32(&s->buf[index]);
- chunk_size = BE_32(&s->buf[index + 4]);
+ chunk_type = AV_RB32(&s->buf[index]);
+ chunk_size = AV_RB32(&s->buf[index + 4]);
switch (chunk_type) {
@@ -391,7 +391,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* convert the RGB palette into the machine's endian format */
if (cpl0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cpl0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cpl0_chunk + 4]);
/* sanity check the palette size */
if (chunk_size / 3 > 256) {
av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: found a palette chunk with %d colors\n",
@@ -419,7 +419,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* decompress the full codebook chunk */
if (cbfz_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbfz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbfz_chunk + 4]);
cbfz_chunk += CHUNK_PREAMBLE_SIZE;
decode_format80(&s->buf[cbfz_chunk], chunk_size,
s->codebook, s->codebook_size, 0);
@@ -428,7 +428,7 @@ static void vqa_decode_chunk(VqaContext *s)
/* copy a full codebook */
if (cbf0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbf0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbf0_chunk + 4]);
/* sanity check the full codebook size */
if (chunk_size > MAX_CODEBOOK_SIZE) {
av_log(s->avctx, AV_LOG_ERROR, " VQA video: problem: CBF0 chunk too large (0x%X bytes)\n",
@@ -448,7 +448,7 @@ static void vqa_decode_chunk(VqaContext *s)
return;
}
- chunk_size = BE_32(&s->buf[vptz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[vptz_chunk + 4]);
vptz_chunk += CHUNK_PREAMBLE_SIZE;
decode_format80(&s->buf[vptz_chunk], chunk_size,
s->decode_buffer, s->decode_buffer_size, 1);
@@ -522,7 +522,7 @@ static void vqa_decode_chunk(VqaContext *s)
if (cbp0_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbp0_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbp0_chunk + 4]);
cbp0_chunk += CHUNK_PREAMBLE_SIZE;
/* accumulate partial codebook */
@@ -545,7 +545,7 @@ static void vqa_decode_chunk(VqaContext *s)
if (cbpz_chunk != -1) {
- chunk_size = BE_32(&s->buf[cbpz_chunk + 4]);
+ chunk_size = AV_RB32(&s->buf[cbpz_chunk + 4]);
cbpz_chunk += CHUNK_PREAMBLE_SIZE;
/* accumulate partial codebook */
diff --git a/src/libffmpeg/libavcodec/wavpack.c b/src/libffmpeg/libavcodec/wavpack.c
index 18544831e..b462174da 100644
--- a/src/libffmpeg/libavcodec/wavpack.c
+++ b/src/libffmpeg/libavcodec/wavpack.c
@@ -141,8 +141,8 @@ static av_always_inline int get_tail(GetBitContext *gb, int k)
{
int p, e, res;
- if(k<1 || k>65535)return 0;
- p = av_log2_16bit(k);
+ if(k<1)return 0;
+ p = av_log2(k);
e = (1 << (p + 1)) - k - 1;
res = p ? get_bits(gb, p) : 0;
if(res >= e){
@@ -387,15 +387,15 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
memset(s->decorr, 0, MAX_TERMS * sizeof(Decorr));
- s->samples = LE_32(buf); buf += 4;
+ s->samples = AV_RL32(buf); buf += 4;
if(!s->samples) return buf_size;
/* should not happen but who knows */
if(s->samples * 2 * avctx->channels > AVCODEC_MAX_AUDIO_FRAME_SIZE){
av_log(avctx, AV_LOG_ERROR, "Packet size is too big to be handled in lavc!\n");
return -1;
}
- s->joint = LE_32(buf) & WV_JOINT; buf += 4;
- s->CRC = LE_32(buf); buf += 4;
+ s->joint = AV_RL32(buf) & WV_JOINT; buf += 4;
+ s->CRC = AV_RL32(buf); buf += 4;
// parse metadata blocks
while(buf < buf_end){
id = *buf++;
@@ -467,23 +467,23 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
t = 0;
for(i = s->terms - 1; (i >= 0) && (t < size); i--) {
if(s->decorr[i].value > 8){
- s->decorr[i].samplesA[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesA[1] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesA[1] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo){
- s->decorr[i].samplesB[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesB[1] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesB[1] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}
t += 4;
}else if(s->decorr[i].value < 0){
- s->decorr[i].samplesA[0] = wp_exp2(LE_16(buf)); buf += 2;
- s->decorr[i].samplesB[0] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[0] = wp_exp2(AV_RL16(buf)); buf += 2;
+ s->decorr[i].samplesB[0] = wp_exp2(AV_RL16(buf)); buf += 2;
t += 4;
}else{
for(j = 0; j < s->decorr[i].value; j++){
- s->decorr[i].samplesA[j] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesA[j] = wp_exp2(AV_RL16(buf)); buf += 2;
if(s->stereo){
- s->decorr[i].samplesB[j] = wp_exp2(LE_16(buf)); buf += 2;
+ s->decorr[i].samplesB[j] = wp_exp2(AV_RL16(buf)); buf += 2;
}
}
t += s->decorr[i].value * 2 * avctx->channels;
@@ -498,7 +498,7 @@ static int wavpack_decode_frame(AVCodecContext *avctx,
continue;
}
for(i = 0; i < 3 * avctx->channels; i++){
- s->median[i] = wp_exp2(LE_16(buf));
+ s->median[i] = wp_exp2(AV_RL16(buf));
buf += 2;
}
got_entropy = 1;
diff --git a/src/libffmpeg/libavcodec/ws-snd1.c b/src/libffmpeg/libavcodec/ws-snd1.c
index eb4fe81d3..3624909a3 100644
--- a/src/libffmpeg/libavcodec/ws-snd1.c
+++ b/src/libffmpeg/libavcodec/ws-snd1.c
@@ -57,9 +57,9 @@ static int ws_snd_decode_frame(AVCodecContext *avctx,
if (!buf_size)
return 0;
- out_size = LE_16(&buf[0]);
+ out_size = AV_RL16(&buf[0]);
*data_size = out_size * 2;
- in_size = LE_16(&buf[2]);
+ in_size = AV_RL16(&buf[2]);
buf += 4;
if (in_size == out_size) {
diff --git a/src/libffmpeg/libavcodec/xan.c b/src/libffmpeg/libavcodec/xan.c
index 56ce87a95..f697514a0 100644
--- a/src/libffmpeg/libavcodec/xan.c
+++ b/src/libffmpeg/libavcodec/xan.c
@@ -296,10 +296,10 @@ static void xan_wc3_decode_frame(XanContext *s) {
unsigned char *vector_segment;
unsigned char *imagedata_segment;
- huffman_segment = s->buf + LE_16(&s->buf[0]);
- size_segment = s->buf + LE_16(&s->buf[2]);
- vector_segment = s->buf + LE_16(&s->buf[4]);
- imagedata_segment = s->buf + LE_16(&s->buf[6]);
+ huffman_segment = s->buf + AV_RL16(&s->buf[0]);
+ size_segment = s->buf + AV_RL16(&s->buf[2]);
+ vector_segment = s->buf + AV_RL16(&s->buf[4]);
+ imagedata_segment = s->buf + AV_RL16(&s->buf[6]);
xan_huffman_decode(opcode_buffer, huffman_segment, opcode_buffer_size);
@@ -350,7 +350,7 @@ static void xan_wc3_decode_frame(XanContext *s) {
case 10:
case 20:
- size = BE_16(&size_segment[0]);
+ size = AV_RB16(&size_segment[0]);
size_segment += 2;
break;
diff --git a/src/libffmpeg/libavcodec/xl.c b/src/libffmpeg/libavcodec/xl.c
index 67ad237e1..8a011d887 100644
--- a/src/libffmpeg/libavcodec/xl.c
+++ b/src/libffmpeg/libavcodec/xl.c
@@ -73,7 +73,7 @@ static int decode_frame(AVCodecContext *avctx,
for (j = 0; j < avctx->width; j += 4) {
/* value is stored in LE dword with word swapped */
- val = LE_32(buf);
+ val = AV_RL32(buf);
buf -= 4;
val = ((val >> 16) & 0xFFFF) | ((val & 0xFFFF) << 16);
diff --git a/src/libffmpeg/libavcodec/zmbv.c b/src/libffmpeg/libavcodec/zmbv.c
index fe3745e09..3b87c7db1 100644
--- a/src/libffmpeg/libavcodec/zmbv.c
+++ b/src/libffmpeg/libavcodec/zmbv.c
@@ -545,7 +545,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_15BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint16_t tmp = LE_16(src);
+ uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0x7C00) >> 7;
out[i * 3 + 1] = (tmp & 0x03E0) >> 2;
@@ -557,7 +557,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_16BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint16_t tmp = LE_16(src);
+ uint16_t tmp = AV_RL16(src);
src += 2;
out[i * 3 + 0] = (tmp & 0xF800) >> 8;
out[i * 3 + 1] = (tmp & 0x07E0) >> 3;
@@ -578,7 +578,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, uint8
case ZMBV_FMT_32BPP:
for(j = 0; j < c->height; j++) {
for(i = 0; i < c->width; i++) {
- uint32_t tmp = LE_32(src);
+ uint32_t tmp = AV_RL32(src);
src += 4;
out[i * 3 + 0] = tmp >> 16;
out[i * 3 + 1] = tmp >> 8;
diff --git a/src/libffmpeg/libavutil/avutil.h b/src/libffmpeg/libavutil/avutil.h
index 08cc61567..d5a4570dc 100644
--- a/src/libffmpeg/libavutil/avutil.h
+++ b/src/libffmpeg/libavutil/avutil.h
@@ -34,8 +34,8 @@ extern "C" {
#define AV_STRINGIFY(s) AV_TOSTRING(s)
#define AV_TOSTRING(s) #s
-#define LIBAVUTIL_VERSION_INT ((49<<16)+(1<<8)+0)
-#define LIBAVUTIL_VERSION 49.1.0
+#define LIBAVUTIL_VERSION_INT ((49<<16)+(2<<8)+0)
+#define LIBAVUTIL_VERSION 49.2.0
#define LIBAVUTIL_BUILD LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_IDENT "Lavu" AV_STRINGIFY(LIBAVUTIL_VERSION)
diff --git a/src/libffmpeg/libavutil/common.h b/src/libffmpeg/libavutil/common.h
index 0e093616c..0c77aa26a 100644
--- a/src/libffmpeg/libavutil/common.h
+++ b/src/libffmpeg/libavutil/common.h
@@ -120,7 +120,7 @@ static inline int av_log2_16bit(unsigned int v)
/* median of 3 */
static inline int mid_pred(int a, int b, int c)
{
-#if HAVE_CMOV
+#ifdef HAVE_CMOV
int i=b;
asm volatile(
"cmp %2, %1 \n\t"
diff --git a/src/libffmpeg/libavutil/intreadwrite.h b/src/libffmpeg/libavutil/intreadwrite.h
index c43f9d651..e6db5ce6f 100644
--- a/src/libffmpeg/libavutil/intreadwrite.h
+++ b/src/libffmpeg/libavutil/intreadwrite.h
@@ -26,17 +26,40 @@ struct unaligned_16 { uint16_t l; } __attribute__((packed));
#endif /* !__GNUC__ */
/* endian macros */
-#if !defined(BE_16) || !defined(BE_32) || !defined(LE_16) || !defined(LE_32)
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
+#define AV_RB8(x) (((uint8_t*)(x))[0])
+#define AV_WB8(p, i, d) { ((uint8_t*)(p))[(i)] = (d); }
+
+#define AV_RB16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
+#define AV_WB16(p, i, d) { \
+ ((uint8_t*)(p))[(i)+1] = (d); \
+ ((uint8_t*)(p))[(i)] = (d)>>8; }
+
+#define AV_RB32(x) ((((uint8_t*)(x))[0] << 24) | \
(((uint8_t*)(x))[1] << 16) | \
(((uint8_t*)(x))[2] << 8) | \
((uint8_t*)(x))[3])
-#define LE_16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
-#define LE_32(x) ((((uint8_t*)(x))[3] << 24) | \
+#define AV_WB32(p, i, d) { \
+ ((uint8_t*)(p))[(i)+3] = (d); \
+ ((uint8_t*)(p))[(i)+2] = (d)>>8; \
+ ((uint8_t*)(p))[(i)+1] = (d)>>16; \
+ ((uint8_t*)(p))[(i)] = (d)>>24; }
+
+#define AV_RL8(x) AV_RB8(x)
+#define AV_WL8(p, i, d) AV_WB8(p, i, d)
+
+#define AV_RL16(x) ((((uint8_t*)(x))[1] << 8) | ((uint8_t*)(x))[0])
+#define AV_WL16(p, i, d) { \
+ ((uint8_t*)(p))[(i)] = (d); \
+ ((uint8_t*)(p))[(i)+1] = (d)>>8; }
+
+#define AV_RL32(x) ((((uint8_t*)(x))[3] << 24) | \
(((uint8_t*)(x))[2] << 16) | \
(((uint8_t*)(x))[1] << 8) | \
((uint8_t*)(x))[0])
-#endif
+#define AV_WL32(p, i, d) { \
+ ((uint8_t*)(p))[(i)] = (d); \
+ ((uint8_t*)(p))[(i)+1] = (d)>>8; \
+ ((uint8_t*)(p))[(i)+2] = (d)>>16; \
+ ((uint8_t*)(p))[(i)+3] = (d)>>24; }
#endif /* INTREADWRITE_H */
diff --git a/src/libffmpeg/libavutil/log.c b/src/libffmpeg/libavutil/log.c
index 8b2dc6f6d..4fd503d0d 100644
--- a/src/libffmpeg/libavutil/log.c
+++ b/src/libffmpeg/libavutil/log.c
@@ -28,7 +28,7 @@
int av_log_level = AV_LOG_INFO;
-static void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
+void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl)
{
static int print_prefix=1;
AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
diff --git a/src/libffmpeg/libavutil/log.h b/src/libffmpeg/libavutil/log.h
index 0ff1f9fcf..56ca01289 100644
--- a/src/libffmpeg/libavutil/log.h
+++ b/src/libffmpeg/libavutil/log.h
@@ -38,10 +38,49 @@ struct AVCLASS {
/* av_log API */
+#if LIBAVUTIL_VERSION_INT < (50<<16)
#define AV_LOG_QUIET -1
+#define AV_LOG_FATAL 0
#define AV_LOG_ERROR 0
+#define AV_LOG_WARNING 1
#define AV_LOG_INFO 1
+#define AV_LOG_VERBOSE 1
#define AV_LOG_DEBUG 2
+#else
+#define AV_LOG_QUIET -8
+
+/**
+ * something went really wrong and we will crash now
+ */
+#define AV_LOG_PANIC 0
+
+/**
+ * something went wrong and recovery is not possible
+ * like no header in a format which depends on it or a combination
+ * of parameters which are not allowed
+ */
+#define AV_LOG_FATAL 8
+
+/**
+ * something went wrong and cannot losslessly be recovered
+ * but not all future data is affected
+ */
+#define AV_LOG_ERROR 16
+
+/**
+ * something somehow does not look correct / something which may or may not
+ * lead to some problems like use of -vstrict -2
+ */
+#define AV_LOG_WARNING 24
+
+#define AV_LOG_INFO 32
+#define AV_LOG_VERBOSE 40
+
+/**
+ * stuff which is only useful for libav* developers
+ */
+#define AV_LOG_DEBUG 48
+#endif
extern int av_log_level;
#ifdef __GNUC__
@@ -55,6 +94,7 @@ extern void av_vlog(void*, int level, const char *fmt, va_list);
extern int av_log_get_level(void);
extern void av_log_set_level(int);
extern void av_log_set_callback(void (*)(void*, int, const char*, va_list));
+extern void av_log_default_callback(void* ptr, int level, const char* fmt, va_list vl);
#else
extern void (*av_vlog)(void*, int, const char*, va_list);
#endif