mirror of
				https://github.com/nyanmisaka/ffmpeg-rockchip.git
				synced 2025-11-01 04:53:04 +08:00 
			
		
		
		
	Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits) frwu: Employ more meaningful return values. fraps: Use av_fast_padded_malloc() instead of av_realloc() mjpegdec: use av_fast_padded_malloc() eatqi: use av_fast_padded_malloc() asv1: use av_fast_padded_malloc() avcodec: Add av_fast_padded_malloc(). swscale: enable dithering in MMX functions. swscale: make rgb24 function macros slightly smaller. avcodec.h: Remove some disabled cruft. swscale: remove obsolete comment. swscale-test: Drop unused argc and argv arguments from main(). zmbv: Employ more meaningful return values. zmbvenc: Employ more meaningful return values. vc1: prevent null pointer dereference on broken files zmbv: check av_realloc() return values and avoid memleaks on ENOMEM truespeech: align buffer ac3: Do not read past the end of ff_ac3_band_start_tab. dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936. dv: Fix null pointer dereference due to ach=0 dv: check stype ... Conflicts: doc/APIchanges libavcodec/asv1.c libavcodec/avcodec.h libavcodec/eatqi.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/zmbv.c libavformat/dv.c libswscale/swscale.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		| @@ -16,6 +16,11 @@ API changes, most recent first: | |||||||
| 2012-01-24 - xxxxxxx - lavfi 2.60.100 | 2012-01-24 - xxxxxxx - lavfi 2.60.100 | ||||||
|   Add avfilter_graph_dump. |   Add avfilter_graph_dump. | ||||||
|  |  | ||||||
|  | 2012-02-01 - xxxxxxx - lavc 54.01.0 | ||||||
|  |   Add av_fast_padded_malloc() as alternative for av_realloc() when aligned | ||||||
|  |   memory is required. The buffer will always have FF_INPUT_BUFFER_PADDING_SIZE | ||||||
|  |   zero-padded bytes at the end. | ||||||
|  |  | ||||||
| 2012-01-31 - xxxxxxx - lavf 54.01.0 | 2012-01-31 - xxxxxxx - lavf 54.01.0 | ||||||
|   Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags(). |   Add avformat_get_riff_video_tags() and avformat_get_riff_audio_tags(). | ||||||
|  |  | ||||||
|   | |||||||
| @@ -109,7 +109,7 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd, | |||||||
|                                      int snr_offset, int floor, |                                      int snr_offset, int floor, | ||||||
|                                      const uint8_t *bap_tab, uint8_t *bap) |                                      const uint8_t *bap_tab, uint8_t *bap) | ||||||
| { | { | ||||||
|     int bin, band; |     int bin, band, band_end; | ||||||
|  |  | ||||||
|     /* special case, if snr offset is -960, set all bap's to zero */ |     /* special case, if snr offset is -960, set all bap's to zero */ | ||||||
|     if (snr_offset == -960) { |     if (snr_offset == -960) { | ||||||
| @@ -121,12 +121,14 @@ static void ac3_bit_alloc_calc_bap_c(int16_t *mask, int16_t *psd, | |||||||
|     band = ff_ac3_bin_to_band_tab[start]; |     band = ff_ac3_bin_to_band_tab[start]; | ||||||
|     do { |     do { | ||||||
|         int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor; |         int m = (FFMAX(mask[band] - snr_offset - floor, 0) & 0x1FE0) + floor; | ||||||
|         int band_end = FFMIN(ff_ac3_band_start_tab[band+1], end); |         band_end = ff_ac3_band_start_tab[++band]; | ||||||
|  |         band_end = FFMIN(band_end, end); | ||||||
|  |  | ||||||
|         for (; bin < band_end; bin++) { |         for (; bin < band_end; bin++) { | ||||||
|             int address = av_clip((psd[bin] - m) >> 5, 0, 63); |             int address = av_clip((psd[bin] - m) >> 5, 0, 63); | ||||||
|             bap[bin] = bap_tab[address]; |             bap[bin] = bap_tab[address]; | ||||||
|         } |         } | ||||||
|     } while (end > ff_ac3_band_start_tab[band++]); |     } while (end > band_end); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap, | static void ac3_update_bap_counts_c(uint16_t mant_cnt[16], uint8_t *bap, | ||||||
|   | |||||||
| @@ -408,7 +408,8 @@ static int decode_frame(AVCodecContext *avctx, | |||||||
|     p->pict_type= AV_PICTURE_TYPE_I; |     p->pict_type= AV_PICTURE_TYPE_I; | ||||||
|     p->key_frame= 1; |     p->key_frame= 1; | ||||||
|  |  | ||||||
|     av_fast_padded_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, buf_size); |     av_fast_padded_malloc(&a->bitstream_buffer, &a->bitstream_buffer_size, | ||||||
|  |                           buf_size); | ||||||
|     if (!a->bitstream_buffer) |     if (!a->bitstream_buffer) | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|  |  | ||||||
|   | |||||||
| @@ -185,9 +185,6 @@ enum CodecID { | |||||||
|     CODEC_ID_TIERTEXSEQVIDEO, |     CODEC_ID_TIERTEXSEQVIDEO, | ||||||
|     CODEC_ID_TIFF, |     CODEC_ID_TIFF, | ||||||
|     CODEC_ID_GIF, |     CODEC_ID_GIF, | ||||||
| #if LIBAVCODEC_VERSION_MAJOR == 53 |  | ||||||
|     CODEC_ID_FFH264, |  | ||||||
| #endif |  | ||||||
|     CODEC_ID_DXA, |     CODEC_ID_DXA, | ||||||
|     CODEC_ID_DNXHD, |     CODEC_ID_DNXHD, | ||||||
|     CODEC_ID_THP, |     CODEC_ID_THP, | ||||||
| @@ -205,10 +202,6 @@ enum CodecID { | |||||||
|     CODEC_ID_INDEO5, |     CODEC_ID_INDEO5, | ||||||
|     CODEC_ID_MIMIC, |     CODEC_ID_MIMIC, | ||||||
|     CODEC_ID_RL2, |     CODEC_ID_RL2, | ||||||
| #if LIBAVCODEC_VERSION_MAJOR == 53 |  | ||||||
|     CODEC_ID_8SVX_EXP, |  | ||||||
|     CODEC_ID_8SVX_FIB, |  | ||||||
| #endif |  | ||||||
|     CODEC_ID_ESCAPE124, |     CODEC_ID_ESCAPE124, | ||||||
|     CODEC_ID_DIRAC, |     CODEC_ID_DIRAC, | ||||||
|     CODEC_ID_BFI, |     CODEC_ID_BFI, | ||||||
| @@ -247,18 +240,13 @@ enum CodecID { | |||||||
|     CODEC_ID_DFA, |     CODEC_ID_DFA, | ||||||
|     CODEC_ID_WMV3IMAGE, |     CODEC_ID_WMV3IMAGE, | ||||||
|     CODEC_ID_VC1IMAGE, |     CODEC_ID_VC1IMAGE, | ||||||
| #if LIBAVCODEC_VERSION_MAJOR == 53 |     CODEC_ID_UTVIDEO, | ||||||
|     CODEC_ID_G723_1_DEPRECATED, |  | ||||||
|     CODEC_ID_G729_DEPRECATED, |  | ||||||
| #endif |  | ||||||
|     CODEC_ID_UTVIDEO_DEPRECATED, |  | ||||||
|     CODEC_ID_BMV_VIDEO, |     CODEC_ID_BMV_VIDEO, | ||||||
|     CODEC_ID_VBLE, |     CODEC_ID_VBLE, | ||||||
|     CODEC_ID_DXTORY, |     CODEC_ID_DXTORY, | ||||||
|     CODEC_ID_V410, |     CODEC_ID_V410, | ||||||
|     CODEC_ID_XWD, |     CODEC_ID_XWD, | ||||||
|     CODEC_ID_Y41P       = MKBETAG('Y','4','1','P'), |     CODEC_ID_Y41P       = MKBETAG('Y','4','1','P'), | ||||||
|     CODEC_ID_UTVIDEO = 0x800, |  | ||||||
|     CODEC_ID_ESCAPE130  = MKBETAG('E','1','3','0'), |     CODEC_ID_ESCAPE130  = MKBETAG('E','1','3','0'), | ||||||
|     CODEC_ID_AVRP       = MKBETAG('A','V','R','P'), |     CODEC_ID_AVRP       = MKBETAG('A','V','R','P'), | ||||||
|  |  | ||||||
| @@ -397,15 +385,11 @@ enum CodecID { | |||||||
|     CODEC_ID_AAC_LATM, |     CODEC_ID_AAC_LATM, | ||||||
|     CODEC_ID_QDMC, |     CODEC_ID_QDMC, | ||||||
|     CODEC_ID_CELT, |     CODEC_ID_CELT, | ||||||
| #if LIBAVCODEC_VERSION_MAJOR > 53 |     CODEC_ID_G723_1, | ||||||
|     CODEC_ID_G723_1_DEPRECATED, |     CODEC_ID_G729, | ||||||
|     CODEC_ID_G729_DEPRECATED, |  | ||||||
|     CODEC_ID_8SVX_EXP, |     CODEC_ID_8SVX_EXP, | ||||||
|     CODEC_ID_8SVX_FIB, |     CODEC_ID_8SVX_FIB, | ||||||
| #endif |  | ||||||
|     CODEC_ID_BMV_AUDIO, |     CODEC_ID_BMV_AUDIO, | ||||||
|     CODEC_ID_G729 = 0x15800, |  | ||||||
|     CODEC_ID_G723_1= 0x15801, |  | ||||||
|     CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'), |     CODEC_ID_FFWAVESYNTH = MKBETAG('F','F','W','S'), | ||||||
|     CODEC_ID_8SVX_RAW   = MKBETAG('8','S','V','X'), |     CODEC_ID_8SVX_RAW   = MKBETAG('8','S','V','X'), | ||||||
|     CODEC_ID_SONIC       = MKBETAG('S','O','N','C'), |     CODEC_ID_SONIC       = MKBETAG('S','O','N','C'), | ||||||
| @@ -1523,7 +1507,6 @@ typedef struct AVCodecContext { | |||||||
| #define FF_BUG_DC_CLIP          4096 | #define FF_BUG_DC_CLIP          4096 | ||||||
| #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders. | #define FF_BUG_MS               8192 ///< Work around various bugs in Microsoft's broken decoders. | ||||||
| #define FF_BUG_TRUNCATED       16384 | #define FF_BUG_TRUNCATED       16384 | ||||||
| //#define FF_BUG_FAKE_SCALABILITY 16 //Autodetection should work 100%. |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * luma single coefficient elimination threshold |      * luma single coefficient elimination threshold | ||||||
| @@ -2096,14 +2079,6 @@ typedef struct AVCodecContext { | |||||||
|      * - decoding: unused |      * - decoding: unused | ||||||
|      */ |      */ | ||||||
|     int context_model; |     int context_model; | ||||||
| #if 0 |  | ||||||
|     /** |  | ||||||
|      * |  | ||||||
|      * - encoding: unused |  | ||||||
|      * - decoding: Set by user. |  | ||||||
|      */ |  | ||||||
|     uint8_t * (*realloc)(struct AVCodecContext *s, uint8_t *buf, int buf_size); |  | ||||||
| #endif |  | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|      * slice flags |      * slice flags | ||||||
|   | |||||||
| @@ -127,7 +127,8 @@ static int tqi_decode_frame(AVCodecContext *avctx, | |||||||
|         return -1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     av_fast_padded_malloc(&t->bitstream_buf, &t->bitstream_buf_size, buf_end-buf); |     av_fast_padded_malloc(&t->bitstream_buf, &t->bitstream_buf_size, | ||||||
|  |                           buf_end - buf); | ||||||
|     if (!t->bitstream_buf) |     if (!t->bitstream_buf) | ||||||
|         return AVERROR(ENOMEM); |         return AVERROR(ENOMEM); | ||||||
|     s->dsp.bswap_buf(t->bitstream_buf, (const uint32_t*)buf, (buf_end-buf)/4); |     s->dsp.bswap_buf(t->bitstream_buf, (const uint32_t*)buf, (buf_end-buf)/4); | ||||||
|   | |||||||
| @@ -28,7 +28,7 @@ static av_cold int decode_init(AVCodecContext *avctx) | |||||||
| { | { | ||||||
|     if (avctx->width & 1) { |     if (avctx->width & 1) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "frwu needs even width\n"); |         av_log(avctx, AV_LOG_ERROR, "frwu needs even width\n"); | ||||||
|         return -1; |         return AVERROR(EINVAL); | ||||||
|     } |     } | ||||||
|     avctx->pix_fmt = PIX_FMT_UYVY422; |     avctx->pix_fmt = PIX_FMT_UYVY422; | ||||||
|  |  | ||||||
| @@ -42,7 +42,7 @@ static av_cold int decode_init(AVCodecContext *avctx) | |||||||
| static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | ||||||
|                         AVPacket *avpkt) |                         AVPacket *avpkt) | ||||||
| { | { | ||||||
|     int field; |     int field, ret; | ||||||
|     AVFrame *pic = avctx->coded_frame; |     AVFrame *pic = avctx->coded_frame; | ||||||
|     const uint8_t *buf = avpkt->data; |     const uint8_t *buf = avpkt->data; | ||||||
|     const uint8_t *buf_end = buf + avpkt->size; |     const uint8_t *buf_end = buf + avpkt->size; | ||||||
| @@ -52,16 +52,18 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |||||||
|  |  | ||||||
|     if (avpkt->size < avctx->width * 2 * avctx->height + 4 + 2*8) { |     if (avpkt->size < avctx->width * 2 * avctx->height + 4 + 2*8) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Packet is too small.\n"); |         av_log(avctx, AV_LOG_ERROR, "Packet is too small.\n"); | ||||||
|         return -1; |         return AVERROR_INVALIDDATA; | ||||||
|     } |     } | ||||||
|     if (bytestream_get_le32(&buf) != AV_RL32("FRW1")) { |     if (bytestream_get_le32(&buf) != AV_RL32("FRW1")) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "incorrect marker\n"); |         av_log(avctx, AV_LOG_ERROR, "incorrect marker\n"); | ||||||
|         return -1; |         return AVERROR_INVALIDDATA; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     pic->reference = 0; |     pic->reference = 0; | ||||||
|     if (avctx->get_buffer(avctx, pic) < 0) |     if ((ret = avctx->get_buffer(avctx, pic)) < 0) { | ||||||
|         return -1; |         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | ||||||
|  |         return ret; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     pic->pict_type = AV_PICTURE_TYPE_I; |     pic->pict_type = AV_PICTURE_TYPE_I; | ||||||
|     pic->key_frame = 1; |     pic->key_frame = 1; | ||||||
| @@ -74,16 +76,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, | |||||||
|         int field_size, min_field_size = avctx->width * 2 * field_h; |         int field_size, min_field_size = avctx->width * 2 * field_h; | ||||||
|         uint8_t *dst = pic->data[0]; |         uint8_t *dst = pic->data[0]; | ||||||
|         if (buf_end - buf < 8) |         if (buf_end - buf < 8) | ||||||
|             return -1; |             return AVERROR_INVALIDDATA; | ||||||
|         buf += 4; // flags? 0x80 == bottom field maybe? |         buf += 4; // flags? 0x80 == bottom field maybe? | ||||||
|         field_size = bytestream_get_le32(&buf); |         field_size = bytestream_get_le32(&buf); | ||||||
|         if (field_size < min_field_size) { |         if (field_size < min_field_size) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Field size %i is too small (required %i)\n", field_size, min_field_size); |             av_log(avctx, AV_LOG_ERROR, "Field size %i is too small (required %i)\n", field_size, min_field_size); | ||||||
|             return -1; |             return AVERROR_INVALIDDATA; | ||||||
|         } |         } | ||||||
|         if (buf_end - buf < field_size) { |         if (buf_end - buf < field_size) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf)); |             av_log(avctx, AV_LOG_ERROR, "Packet is too small, need %i, have %i\n", field_size, (int)(buf_end - buf)); | ||||||
|             return -1; |             return AVERROR_INVALIDDATA; | ||||||
|         } |         } | ||||||
|         if (field) |         if (field) | ||||||
|             dst += pic->linesize[0]; |             dst += pic->linesize[0]; | ||||||
|   | |||||||
| @@ -21,52 +21,80 @@ | |||||||
| #include <stdint.h> | #include <stdint.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
|  |  | ||||||
| #include "avcodec.h" | #include "libavutil/mem.h" | ||||||
| #include "dsputil.h" |  | ||||||
| #include "get_bits.h" | #include "get_bits.h" | ||||||
| #include "golomb.h" | #include "golomb.h" | ||||||
| #include "put_bits.h" | #include "put_bits.h" | ||||||
|  |  | ||||||
| #undef printf | #undef fprintf | ||||||
| #define COUNT 8000 | #define COUNT 8191 | ||||||
| #define SIZE (COUNT * 40) | #define SIZE (COUNT * 4) | ||||||
|  |  | ||||||
| int main(void) | int main(void) | ||||||
| { | { | ||||||
|     int i; |     int i, ret = 0; | ||||||
|     uint8_t temp[SIZE]; |     uint8_t *temp; | ||||||
|     PutBitContext pb; |     PutBitContext pb; | ||||||
|     GetBitContext gb; |     GetBitContext gb; | ||||||
|  |  | ||||||
|  |     temp = av_malloc(SIZE); | ||||||
|  |     if (!temp) | ||||||
|  |         return 2; | ||||||
|  |  | ||||||
|     init_put_bits(&pb, temp, SIZE); |     init_put_bits(&pb, temp, SIZE); | ||||||
|     printf("testing unsigned exp golomb\n"); |  | ||||||
|     for (i = 0; i < COUNT; i++) |     for (i = 0; i < COUNT; i++) | ||||||
|         set_ue_golomb(&pb, i); |         set_ue_golomb(&pb, i); | ||||||
|     flush_put_bits(&pb); |     flush_put_bits(&pb); | ||||||
|  |  | ||||||
|     init_get_bits(&gb, temp, 8 * SIZE); |     init_get_bits(&gb, temp, 8 * SIZE); | ||||||
|     for (i = 0; i < COUNT; i++) { |     for (i = 0; i < COUNT; i++) { | ||||||
|         int j, s = show_bits(&gb, 24); |         int j, s = show_bits(&gb, 25); | ||||||
|  |  | ||||||
|         j = get_ue_golomb(&gb); |         j = get_ue_golomb(&gb); | ||||||
|         if (j != i) |         if (j != i) { | ||||||
|             printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s); |             fprintf(stderr, "get_ue_golomb: expected %d, got %d. bits: %7x\n", | ||||||
|  |                     i, j, s); | ||||||
|  |             ret = 1; | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | #define EXTEND(i) (i << 3 | i & 7) | ||||||
|  |     init_put_bits(&pb, temp, SIZE); | ||||||
|  |     for (i = 0; i < COUNT; i++) | ||||||
|  |         set_ue_golomb(&pb, EXTEND(i)); | ||||||
|  |     flush_put_bits(&pb); | ||||||
|  |  | ||||||
|  |     init_get_bits(&gb, temp, 8 * SIZE); | ||||||
|  |     for (i = 0; i < COUNT; i++) { | ||||||
|  |         int j, s = show_bits_long(&gb, 32); | ||||||
|  |  | ||||||
|  |         j = get_ue_golomb_long(&gb); | ||||||
|  |         if (j != EXTEND(i)) { | ||||||
|  |             fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. " | ||||||
|  |                     "bits: %8x\n", EXTEND(i), j, s); | ||||||
|  |             ret = 1; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     init_put_bits(&pb, temp, SIZE); |     init_put_bits(&pb, temp, SIZE); | ||||||
|     printf("testing signed exp golomb\n"); |  | ||||||
|     for (i = 0; i < COUNT; i++) |     for (i = 0; i < COUNT; i++) | ||||||
|         set_se_golomb(&pb, i - COUNT / 2); |         set_se_golomb(&pb, i - COUNT / 2); | ||||||
|     flush_put_bits(&pb); |     flush_put_bits(&pb); | ||||||
|  |  | ||||||
|     init_get_bits(&gb, temp, 8 * SIZE); |     init_get_bits(&gb, temp, 8 * SIZE); | ||||||
|     for (i = 0; i < COUNT; i++) { |     for (i = 0; i < COUNT; i++) { | ||||||
|         int j, s = show_bits(&gb, 24); |         int j, s = show_bits(&gb, 25); | ||||||
|  |  | ||||||
|         j = get_se_golomb(&gb); |         j = get_se_golomb(&gb); | ||||||
|         if (j != i - COUNT / 2) |         if (j != i - COUNT / 2) { | ||||||
|             printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s); |             fprintf(stderr, "get_se_golomb: expected %d, got %d. bits: %7x\n", | ||||||
|  |                     i - COUNT / 2, j, s); | ||||||
|  |             ret = 1; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return 0; |     av_free(temp); | ||||||
|  |  | ||||||
|  |     return ret; | ||||||
| } | } | ||||||
|   | |||||||
| @@ -37,7 +37,7 @@ typedef struct { | |||||||
|     AVFrame frame; |     AVFrame frame; | ||||||
|     DSPContext dsp; |     DSPContext dsp; | ||||||
|     /* input data */ |     /* input data */ | ||||||
|     uint8_t buffer[32]; |     DECLARE_ALIGNED(16, uint8_t, buffer)[32]; | ||||||
|     int16_t vector[8];  ///< input vector: 5/5/4/4/4/3/3/3 |     int16_t vector[8];  ///< input vector: 5/5/4/4/4/3/3/3 | ||||||
|     int offset1[2];     ///< 8-bit value, used in one copying offset |     int offset1[2];     ///< 8-bit value, used in one copying offset | ||||||
|     int offset2[4];     ///< 7-bit value, encodes offsets for copying and for two-point filter |     int offset2[4];     ///< 7-bit value, encodes offsets for copying and for two-point filter | ||||||
|   | |||||||
| @@ -91,7 +91,7 @@ void av_fast_padded_malloc(void *ptr, unsigned int *size, size_t min_size) | |||||||
| { | { | ||||||
|     uint8_t **p = ptr; |     uint8_t **p = ptr; | ||||||
|     if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { |     if (min_size > SIZE_MAX - FF_INPUT_BUFFER_PADDING_SIZE) { | ||||||
|         *p = NULL; |         av_freep(p); | ||||||
|         *size = 0; |         *size = 0; | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| @@ -1448,9 +1448,9 @@ av_cold int avcodec_close(AVCodecContext *avctx) | |||||||
| static enum CodecID remap_deprecated_codec_id(enum CodecID id) | static enum CodecID remap_deprecated_codec_id(enum CodecID id) | ||||||
| { | { | ||||||
|     switch(id){ |     switch(id){ | ||||||
|         case CODEC_ID_G723_1_DEPRECATED : return CODEC_ID_G723_1; |         //This is for future deprecatec codec ids, its empty since | ||||||
|         case CODEC_ID_G729_DEPRECATED   : return CODEC_ID_G729; |         //last major bump but will fill up again over time, please dont remove it | ||||||
|         case CODEC_ID_UTVIDEO_DEPRECATED: return CODEC_ID_UTVIDEO; | //         case CODEC_ID_UTVIDEO_DEPRECATED: return CODEC_ID_UTVIDEO; | ||||||
|         default                         : return id; |         default                         : return id; | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -5712,7 +5712,7 @@ static int vc1_decode_frame(AVCodecContext *avctx, void *data, | |||||||
|             if (!v->field_mode || v->second_field) |             if (!v->field_mode || v->second_field) | ||||||
|                 s->end_mb_y = (i == n_slices     ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); |                 s->end_mb_y = (i == n_slices     ) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); | ||||||
|             else |             else | ||||||
|                 s->end_mb_y = (i == n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); |                 s->end_mb_y = (i <= n_slices1 + 1) ? mb_height : FFMIN(mb_height, slices[i].mby_start % mb_height); | ||||||
|             vc1_decode_blocks(v); |             vc1_decode_blocks(v); | ||||||
|             if (i != n_slices) |             if (i != n_slices) | ||||||
|                 s->gb = slices[i].gb; |                 s->gb = slices[i].gb; | ||||||
|   | |||||||
| @@ -403,16 +403,17 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac | |||||||
|     ZmbvContext * const c = avctx->priv_data; |     ZmbvContext * const c = avctx->priv_data; | ||||||
|     int zret = Z_OK; // Zlib return code |     int zret = Z_OK; // Zlib return code | ||||||
|     int len = buf_size; |     int len = buf_size; | ||||||
|     int hi_ver, lo_ver; |     int hi_ver, lo_ver, ret; | ||||||
|  |     uint8_t *tmp; | ||||||
|  |  | ||||||
|     if (c->pic.data[0]) |     if (c->pic.data[0]) | ||||||
|             avctx->release_buffer(avctx, &c->pic); |             avctx->release_buffer(avctx, &c->pic); | ||||||
|  |  | ||||||
|     c->pic.reference = 3; |     c->pic.reference = 3; | ||||||
|     c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; |     c->pic.buffer_hints = FF_BUFFER_HINTS_VALID; | ||||||
|     if (avctx->get_buffer(avctx, &c->pic) < 0) { |     if ((ret = avctx->get_buffer(avctx, &c->pic)) < 0) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |         av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); | ||||||
|         return -1; |         return ret; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /* parse header */ |     /* parse header */ | ||||||
| @@ -434,19 +435,19 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac | |||||||
|                "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n", |                "Flags=%X ver=%i.%i comp=%i fmt=%i blk=%ix%i\n", | ||||||
|                c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh); |                c->flags,hi_ver,lo_ver,c->comp,c->fmt,c->bw,c->bh); | ||||||
|         if (hi_ver != 0 || lo_ver != 1) { |         if (hi_ver != 0 || lo_ver != 1) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Unsupported version %i.%i\n", |             av_log_ask_for_sample(avctx, "Unsupported version %i.%i\n", | ||||||
|             hi_ver, lo_ver); |                                   hi_ver, lo_ver); | ||||||
|             return -1; |             return AVERROR_PATCHWELCOME; | ||||||
|         } |         } | ||||||
|         if (c->bw == 0 || c->bh == 0) { |         if (c->bw == 0 || c->bh == 0) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Unsupported block size %ix%i\n", |             av_log_ask_for_sample(avctx, "Unsupported block size %ix%i\n", | ||||||
|                    c->bw, c->bh); |                                   c->bw, c->bh); | ||||||
|             return -1; |             return AVERROR_PATCHWELCOME; | ||||||
|         } |         } | ||||||
|         if (c->comp != 0 && c->comp != 1) { |         if (c->comp != 0 && c->comp != 1) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, "Unsupported compression type %i\n", |             av_log_ask_for_sample(avctx, "Unsupported compression type %i\n", | ||||||
|                    c->comp); |                                   c->comp); | ||||||
|             return -1; |             return AVERROR_PATCHWELCOME; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         switch (c->fmt) { |         switch (c->fmt) { | ||||||
| @@ -475,9 +476,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac | |||||||
|             break; |             break; | ||||||
|         default: |         default: | ||||||
|             c->decode_xor = NULL; |             c->decode_xor = NULL; | ||||||
|             av_log(avctx, AV_LOG_ERROR, |             av_log_ask_for_sample(avctx, "Unsupported (for now) format %i\n", | ||||||
|                    "Unsupported (for now) format %i\n", c->fmt); |                                   c->fmt); | ||||||
|             return -1; |             return AVERROR_PATCHWELCOME; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         zret = inflateReset(&c->zstream); |         zret = inflateReset(&c->zstream); | ||||||
| @@ -495,10 +496,10 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac | |||||||
|         c->decode_intra= decode_intra; |         c->decode_intra= decode_intra; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     if (c->decode_intra == NULL) { |      if (c->decode_intra == NULL) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n"); |          av_log(avctx, AV_LOG_ERROR, "Error! Got no format or no keyframe!\n"); | ||||||
|         return -1; |          return AVERROR_INVALIDDATA; | ||||||
|     } |      } | ||||||
|  |  | ||||||
|     if (c->comp == 0) { //Uncompressed data |     if (c->comp == 0) { //Uncompressed data | ||||||
|         memcpy(c->decomp_buf, buf, len); |         memcpy(c->decomp_buf, buf, len); | ||||||
| @@ -628,7 +629,7 @@ static av_cold int decode_init(AVCodecContext *avctx) | |||||||
|         if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { |         if ((c->decomp_buf = av_malloc(c->decomp_size)) == NULL) { | ||||||
|             av_log(avctx, AV_LOG_ERROR, |             av_log(avctx, AV_LOG_ERROR, | ||||||
|                    "Can't allocate decompression buffer.\n"); |                    "Can't allocate decompression buffer.\n"); | ||||||
|             return 1; |             return AVERROR(ENOMEM); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -638,7 +639,7 @@ static av_cold int decode_init(AVCodecContext *avctx) | |||||||
|     zret = inflateInit(&c->zstream); |     zret = inflateInit(&c->zstream); | ||||||
|     if (zret != Z_OK) { |     if (zret != Z_OK) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); |         av_log(avctx, AV_LOG_ERROR, "Inflate init error: %d\n", zret); | ||||||
|         return 1; |         return -1; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return 0; |     return 0; | ||||||
|   | |||||||
| @@ -265,7 +265,7 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||||
|         lvl = avctx->compression_level; |         lvl = avctx->compression_level; | ||||||
|     if(lvl < 0 || lvl > 9){ |     if(lvl < 0 || lvl > 9){ | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Compression level should be 0-9, not %i\n", lvl); |         av_log(avctx, AV_LOG_ERROR, "Compression level should be 0-9, not %i\n", lvl); | ||||||
|         return -1; |         return AVERROR(EINVAL); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     // Needed if zlib unused or init aborted before deflateInit |     // Needed if zlib unused or init aborted before deflateInit | ||||||
| @@ -274,7 +274,7 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||||
|         ((avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4; |         ((avctx->width + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * ((avctx->height + ZMBV_BLOCK - 1) / ZMBV_BLOCK) * 2 + 4; | ||||||
|     if ((c->work_buf = av_malloc(c->comp_size)) == NULL) { |     if ((c->work_buf = av_malloc(c->comp_size)) == NULL) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Can't allocate work buffer.\n"); |         av_log(avctx, AV_LOG_ERROR, "Can't allocate work buffer.\n"); | ||||||
|         return -1; |         return AVERROR(ENOMEM); | ||||||
|     } |     } | ||||||
|     /* Conservative upper bound taken from zlib v1.2.1 source via lcl.c */ |     /* Conservative upper bound taken from zlib v1.2.1 source via lcl.c */ | ||||||
|     c->comp_size = c->comp_size + ((c->comp_size + 7) >> 3) + |     c->comp_size = c->comp_size + ((c->comp_size + 7) >> 3) + | ||||||
| @@ -283,12 +283,12 @@ static av_cold int encode_init(AVCodecContext *avctx) | |||||||
|     /* Allocate compression buffer */ |     /* Allocate compression buffer */ | ||||||
|     if ((c->comp_buf = av_malloc(c->comp_size)) == NULL) { |     if ((c->comp_buf = av_malloc(c->comp_size)) == NULL) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); |         av_log(avctx, AV_LOG_ERROR, "Can't allocate compression buffer.\n"); | ||||||
|         return -1; |         return AVERROR(ENOMEM); | ||||||
|     } |     } | ||||||
|     c->pstride = FFALIGN(avctx->width, 16); |     c->pstride = FFALIGN(avctx->width, 16); | ||||||
|     if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) { |     if ((c->prev = av_malloc(c->pstride * avctx->height)) == NULL) { | ||||||
|         av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n"); |         av_log(avctx, AV_LOG_ERROR, "Can't allocate picture.\n"); | ||||||
|         return -1; |         return AVERROR(ENOMEM); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     c->zstream.zalloc = Z_NULL; |     c->zstream.zalloc = Z_NULL; | ||||||
|   | |||||||
| @@ -138,6 +138,7 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], | |||||||
|         pcm = ppcm[ipcm++]; |         pcm = ppcm[ipcm++]; | ||||||
|         if (!pcm) |         if (!pcm) | ||||||
|             break; |             break; | ||||||
|  |  | ||||||
|         /* for each DIF segment */ |         /* for each DIF segment */ | ||||||
|         for (i = 0; i < sys->difseg_size; i++) { |         for (i = 0; i < sys->difseg_size; i++) { | ||||||
|             frame += 6 * 80; /* skip DIF segment header */ |             frame += 6 * 80; /* skip DIF segment header */ | ||||||
| @@ -186,8 +187,6 @@ static int dv_extract_audio(uint8_t* frame, uint8_t* ppcm[4], | |||||||
|                 frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ |                 frame += 16 * 80; /* 15 Video DIFs + 1 Audio DIF */ | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|         /* next stereo channel (50Mbps and 100Mbps only) */ |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     return size; |     return size; | ||||||
|   | |||||||
| @@ -137,10 +137,7 @@ static int swf_read_packet(AVFormatContext *s, AVPacket *pkt) | |||||||
|             ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15); |             ast->codec->codec_id = ff_codec_get_id(swf_audio_codec_tags, (v>>4) & 15); | ||||||
|             ast->need_parsing = AVSTREAM_PARSE_FULL; |             ast->need_parsing = AVSTREAM_PARSE_FULL; | ||||||
|             sample_rate_code= (v>>2) & 3; |             sample_rate_code= (v>>2) & 3; | ||||||
|             if (!sample_rate_code) |             ast->codec->sample_rate = 44100 >> (3 - sample_rate_code); | ||||||
|                 ast->codec->sample_rate = 5512; |  | ||||||
|             else |  | ||||||
|                 ast->codec->sample_rate = 11025 << (sample_rate_code-1); |  | ||||||
|             avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); |             avpriv_set_pts_info(ast, 64, 1, ast->codec->sample_rate); | ||||||
|             len -= 4; |             len -= 4; | ||||||
|         } else if (tag == TAG_VIDEOFRAME) { |         } else if (tag == TAG_VIDEOFRAME) { | ||||||
|   | |||||||
| @@ -1736,8 +1736,6 @@ static void monoblack2Y_c(int16_t *dst, const uint8_t *src, const uint8_t *unuse | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| //FIXME yuy2* can read up to 7 samples too much |  | ||||||
|  |  | ||||||
| static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width, | static void yuy2ToY_c(uint8_t *dst, const uint8_t *src, const uint8_t *unused1, const uint8_t *unused2,  int width, | ||||||
|                       uint32_t *unused) |                       uint32_t *unused) | ||||||
| { | { | ||||||
|   | |||||||
| @@ -271,31 +271,28 @@ cglobal %2 %+ 24ToUV, 7, 7, %1, dstU, dstV, u1, src, u2, w, u3 | |||||||
| %endif ; ARCH_X86_64 && %0 == 3 | %endif ; ARCH_X86_64 && %0 == 3 | ||||||
| %endmacro | %endmacro | ||||||
|  |  | ||||||
|  | ; %1 = nr. of XMM registers for rgb-to-Y func | ||||||
|  | ; %2 = nr. of XMM registers for rgb-to-UV func | ||||||
|  | %macro RGB24_FUNCS 2 | ||||||
|  | RGB24_TO_Y_FN %1, rgb | ||||||
|  | RGB24_TO_Y_FN %1, bgr, rgb | ||||||
|  | RGB24_TO_UV_FN %2, rgb | ||||||
|  | RGB24_TO_UV_FN %2, bgr, rgb | ||||||
|  | %endmacro | ||||||
|  |  | ||||||
| %if ARCH_X86_32 | %if ARCH_X86_32 | ||||||
| INIT_MMX mmx | INIT_MMX mmx | ||||||
| RGB24_TO_Y_FN 0, rgb | RGB24_FUNCS 0, 0 | ||||||
| RGB24_TO_Y_FN 0, bgr, rgb |  | ||||||
| RGB24_TO_UV_FN 0, rgb |  | ||||||
| RGB24_TO_UV_FN 0, bgr, rgb |  | ||||||
| %endif | %endif | ||||||
|  |  | ||||||
| INIT_XMM sse2 | INIT_XMM sse2 | ||||||
| RGB24_TO_Y_FN 10, rgb | RGB24_FUNCS 10, 12 | ||||||
| RGB24_TO_Y_FN 10, bgr, rgb |  | ||||||
| RGB24_TO_UV_FN 12, rgb |  | ||||||
| RGB24_TO_UV_FN 12, bgr, rgb |  | ||||||
|  |  | ||||||
| INIT_XMM ssse3 | INIT_XMM ssse3 | ||||||
| RGB24_TO_Y_FN 11, rgb | RGB24_FUNCS 11, 13 | ||||||
| RGB24_TO_Y_FN 11, bgr, rgb |  | ||||||
| RGB24_TO_UV_FN 13, rgb |  | ||||||
| RGB24_TO_UV_FN 13, bgr, rgb |  | ||||||
|  |  | ||||||
| INIT_XMM avx | INIT_XMM avx | ||||||
| RGB24_TO_Y_FN 11, rgb | RGB24_FUNCS 11, 13 | ||||||
| RGB24_TO_Y_FN 11, bgr, rgb |  | ||||||
| RGB24_TO_UV_FN 13, rgb |  | ||||||
| RGB24_TO_UV_FN 13, bgr, rgb |  | ||||||
|  |  | ||||||
| ;----------------------------------------------------------------------------- | ;----------------------------------------------------------------------------- | ||||||
| ; YUYV/UYVY/NV12/NV21 packed pixel shuffling. | ; YUYV/UYVY/NV12/NV21 packed pixel shuffling. | ||||||
|   | |||||||
| @@ -27,6 +27,8 @@ | |||||||
| #include "libavutil/cpu.h" | #include "libavutil/cpu.h" | ||||||
| #include "libavutil/pixdesc.h" | #include "libavutil/pixdesc.h" | ||||||
|  |  | ||||||
|  | #define DITHER1XBPP | ||||||
|  |  | ||||||
| DECLARE_ASM_CONST(8, uint64_t, bF8)=       0xF8F8F8F8F8F8F8F8LL; | DECLARE_ASM_CONST(8, uint64_t, bF8)=       0xF8F8F8F8F8F8F8F8LL; | ||||||
| DECLARE_ASM_CONST(8, uint64_t, bFC)=       0xFCFCFCFCFCFCFCFCLL; | DECLARE_ASM_CONST(8, uint64_t, bFC)=       0xFCFCFCFCFCFCFCFCLL; | ||||||
| DECLARE_ASM_CONST(8, uint64_t, w10)=       0x0010001000100010LL; | DECLARE_ASM_CONST(8, uint64_t, w10)=       0x0010001000100010LL; | ||||||
|   | |||||||
| @@ -1,6 +1,7 @@ | |||||||
| FATE_TESTS += fate-golomb | FATE_TESTS += fate-golomb | ||||||
| fate-golomb: libavcodec/golomb-test$(EXESUF) | fate-golomb: libavcodec/golomb-test$(EXESUF) | ||||||
| fate-golomb: CMD = run libavcodec/golomb-test | fate-golomb: CMD = run libavcodec/golomb-test | ||||||
|  | fate-golomb: REF = /dev/null | ||||||
|  |  | ||||||
| FATE_TESTS += fate-iirfilter | FATE_TESTS += fate-iirfilter | ||||||
| fate-iirfilter: libavcodec/iirfilter-test$(EXESUF) | fate-iirfilter: libavcodec/iirfilter-test$(EXESUF) | ||||||
|   | |||||||
| @@ -1,2 +0,0 @@ | |||||||
| testing unsigned exp golomb |  | ||||||
| testing signed exp golomb |  | ||||||
		Reference in New Issue
	
	Block a user
	 Michael Niedermayer
					Michael Niedermayer