summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-05-13 04:40:40 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-05-13 04:40:40 +0200
commit72153419b52c96b1ed4a1bfb7e7793ddde7d71b2 (patch)
tree2e5b40aecf44ad40dd0d6bf122fd8918a889805e /libavcodec
parent410ca3bc2d5e95078f3d6698a2f9e53c2fd24f95 (diff)
parent552a99957f7c6f6ed13795caee7ab7b9deb5d76e (diff)
Merge remote branch 'qatar/master'
* qatar/master: (33 commits) rtpdec_qdm2: Don't try to parse data packet if no configuration is received ac3enc: put the counting of stereo rematrixing bits in the same place to make the code easier to understand. ac3enc: clean up count_frame_bits() and count_frame_bits_fixed() mpegvideo: make FF_DEBUG_DCT_COEFF output coeffs via av_log() instead of just via AVFrame. srtdec: make sure we don't write past the end of buffer wmaenc: improve channel count and bitrate error handling in encode_init() matroskaenc: make sure we don't produce invalid file with no codec ID matroskadec: check that pointers were initialized before accessing them lavf: fix function name in compute_pkt_fields2 av_dlog message lavf: fix av_find_best_stream when providing a wanted stream. lavf: fix av_find_best_stream when decoder_ret is given and using a related stream. ffmpeg: factorize quality calculation tiff: add support for SamplesPerPixel tag in tiff_decode_tag() tiff: Prefer enum TiffCompr over int for TiffContext.compr. mov: Support edit list atom version 1. configure: Enable libpostproc automatically if GPL code is enabled. Cosmetics: fix prototypes in oggdec oggdec: fix memleak with continuous streams. matroskaenc: add missing new line in av_log() call dnxhdenc: add AVClass in private context. ... swscale changes largely rewritten by me or replaced by baptsites due to lots of bugs in ronalds code. Above code is also just in case its not obvios to a large extended duplicates that where cherry picked from ffmpeg. Conflicts: configure ffmpeg.c libavformat/matroskaenc.c libavutil/pixfmt.h libswscale/ppc/swscale_template.c libswscale/swscale.c libswscale/swscale_template.c libswscale/utils.c libswscale/x86/swscale_template.c tests/fate/h264.mak tests/ref/lavfi/pixdesc_le tests/ref/lavfi/pixfmts_copy_le tests/ref/lavfi/pixfmts_null_le tests/ref/lavfi/pixfmts_scale_le tests/ref/lavfi/pixfmts_vflip_le Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/ac3enc.c69
-rw-r--r--libavcodec/cavs.h11
-rw-r--r--libavcodec/cavsdata.h8
-rw-r--r--libavcodec/ffv1.c31
-rw-r--r--libavcodec/jfdctfst.c18
-rw-r--r--libavcodec/jfdctint.c18
-rw-r--r--libavcodec/libxvidff.c3
-rw-r--r--libavcodec/tiff.c122
-rw-r--r--libavcodec/vorbis.c8
-rw-r--r--libavcodec/vorbis.h10
-rw-r--r--libavcodec/vorbisdec.c153
-rw-r--r--libavcodec/vorbisenc.c6
12 files changed, 248 insertions, 209 deletions
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 90d65bf44d..eb5a0f94e3 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -791,35 +791,53 @@ static void count_frame_bits_fixed(AC3EncodeContext *s)
* no auxilliary data
*/
- /* header size */
+ /* header */
frame_bits = 65;
frame_bits += frame_bits_inc[s->channel_mode];
/* audio blocks */
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
- frame_bits += s->fbw_channels * 2 + 2; /* blksw * c, dithflag * c, dynrnge, cplstre */
- if (s->channel_mode == AC3_CHMODE_STEREO) {
- frame_bits++; /* rematstr */
- }
- frame_bits += 2 * s->fbw_channels; /* chexpstr[2] * c */
+ /* block switch flags */
+ frame_bits += s->fbw_channels;
+
+ /* dither flags */
+ frame_bits += s->fbw_channels;
+
+ /* dynamic range */
+ frame_bits++;
+
+ /* coupling strategy */
+ frame_bits++;
+ if (!blk)
+ frame_bits++;
+
+ /* exponent strategy */
+ frame_bits += 2 * s->fbw_channels;
if (s->lfe_on)
- frame_bits++; /* lfeexpstr */
- frame_bits++; /* baie */
- frame_bits++; /* snr */
- frame_bits += 2; /* delta / skip */
+ frame_bits++;
+
+ /* bit allocation params */
+ frame_bits++;
+ if (!blk)
+ frame_bits += 2 + 2 + 2 + 2 + 3;
+
+ /* snr offsets and fast gain codes */
+ frame_bits++;
+ if (!blk)
+ frame_bits += 6 + s->channels * (4 + 3);
+
+ /* delta bit allocation */
+ frame_bits++;
+
+ /* skipped data */
+ frame_bits++;
}
- frame_bits++; /* cplinu for block 0 */
- /* bit alloc info */
- /* sdcycod[2], fdcycod[2], sgaincod[2], dbpbcod[2], floorcod[3] */
- /* csnroffset[6] */
- /* (fsnoffset[4] + fgaincod[4]) * c */
- frame_bits += 2*4 + 3 + 6 + s->channels * (4 + 3);
- /* auxdatae, crcrsv */
- frame_bits += 2;
+ /* auxiliary data */
+ frame_bits++;
/* CRC */
- frame_bits += 16;
+ frame_bits += 1 + 16;
s->frame_bits_fixed = frame_bits;
}
@@ -869,6 +887,7 @@ static void count_frame_bits(AC3EncodeContext *s)
int blk, ch;
int frame_bits = 0;
+ /* header */
if (opt->audio_production_info)
frame_bits += 7;
if (s->bitstream_id == 6) {
@@ -878,18 +897,22 @@ static void count_frame_bits(AC3EncodeContext *s)
frame_bits += 14;
}
+ /* audio blocks */
for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) {
/* stereo rematrixing */
- if (s->channel_mode == AC3_CHMODE_STEREO &&
- s->blocks[blk].new_rematrixing_strategy) {
- frame_bits += s->num_rematrixing_bands;
+ if (s->channel_mode == AC3_CHMODE_STEREO) {
+ frame_bits++;
+ if (s->blocks[blk].new_rematrixing_strategy)
+ frame_bits += s->num_rematrixing_bands;
}
+ /* bandwidth codes & gain range */
for (ch = 0; ch < s->fbw_channels; ch++) {
if (s->exp_strategy[ch][blk] != EXP_REUSE)
- frame_bits += 6 + 2; /* chbwcod[6], gainrng[2] */
+ frame_bits += 6 + 2;
}
}
+
s->frame_bits = s->frame_bits_fixed + frame_bits;
}
diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h
index e84d318977..cb4ab2630b 100644
--- a/libavcodec/cavs.h
+++ b/libavcodec/cavs.h
@@ -233,15 +233,16 @@ extern const struct dec_2dvlc ff_cavs_chroma_dec[5];
extern const uint8_t ff_cavs_chroma_qp[64];
extern const uint8_t ff_cavs_scan3x3[4];
extern const uint8_t ff_cavs_partition_flags[30];
-extern const int_fast8_t ff_left_modifier_l[8];
-extern const int_fast8_t ff_top_modifier_l[8];
-extern const int_fast8_t ff_left_modifier_c[7];
-extern const int_fast8_t ff_top_modifier_c[7];
+extern const int8_t ff_left_modifier_l[8];
+extern const int8_t ff_top_modifier_l[8];
+extern const int8_t ff_left_modifier_c[7];
+extern const int8_t ff_top_modifier_c[7];
extern const cavs_vector ff_cavs_intra_mv;
extern const cavs_vector ff_cavs_un_mv;
extern const cavs_vector ff_cavs_dir_mv;
-static inline void modify_pred(const int_fast8_t *mod_table, int *mode) {
+static inline void modify_pred(const int8_t *mod_table, int *mode)
+{
*mode = mod_table[*mode];
if(*mode < 0) {
av_log(NULL, AV_LOG_ERROR, "Illegal intra prediction mode\n");
diff --git a/libavcodec/cavsdata.h b/libavcodec/cavsdata.h
index 9e52fd5cc4..a93405d380 100644
--- a/libavcodec/cavsdata.h
+++ b/libavcodec/cavsdata.h
@@ -497,9 +497,9 @@ static const uint8_t tc_tab[64] = {
5, 5, 5, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 9, 9, 9
};
-const int_fast8_t ff_left_modifier_l[8] = { 0,-1, 6,-1,-1, 7, 6, 7};
-const int_fast8_t ff_top_modifier_l[8] = {-1, 1, 5,-1,-1, 5, 7, 7};
-const int_fast8_t ff_left_modifier_c[7] = { 5,-1, 2,-1, 6, 5, 6};
-const int_fast8_t ff_top_modifier_c[7] = { 4, 1,-1,-1, 4, 6, 6};
+const int8_t ff_left_modifier_l[8] = { 0, -1, 6, -1, -1, 7, 6, 7 };
+const int8_t ff_top_modifier_l[8] = { -1, 1, 5, -1, -1, 5, 7, 7 };
+const int8_t ff_left_modifier_c[7] = { 5, -1, 2, -1, 6, 5, 6 };
+const int8_t ff_top_modifier_c[7] = { 4, 1, -1, -1, 4, 6, 6 };
#endif /* AVCODEC_CAVSDATA_H */
diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 8c1e3d301f..4e0e5f7b62 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -250,7 +250,7 @@ typedef struct FFV1Context{
uint8_t (*initial_states[MAX_QUANT_TABLES])[32];
int run_index;
int colorspace;
- int_fast16_t *sample_buffer;
+ int16_t *sample_buffer;
int gob_count;
int packed_at_lsb;
@@ -280,7 +280,8 @@ static av_always_inline int fold(int diff, int bits){
return diff;
}
-static inline int predict(int_fast16_t *src, int_fast16_t *last){
+static inline int predict(int16_t *src, int16_t *last)
+{
const int LT= last[-1];
const int T= last[ 0];
const int L = src[-1];
@@ -288,7 +289,9 @@ static inline int predict(int_fast16_t *src, int_fast16_t *last){
return mid_pred(L, L + T - LT, T);
}
-static inline int get_context(PlaneContext *p, int_fast16_t *src, int_fast16_t *last, int_fast16_t *last2){
+static inline int get_context(PlaneContext *p, int16_t *src,
+ int16_t *last, int16_t *last2)
+{
const int LT= last[-1];
const int T= last[ 0];
const int RT= last[ 1];
@@ -507,7 +510,10 @@ static inline int get_vlc_symbol(GetBitContext *gb, VlcState * const state, int
}
#if CONFIG_FFV1_ENCODER
-static av_always_inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
+static av_always_inline int encode_line(FFV1Context *s, int w,
+ int16_t *sample[2],
+ int plane_index, int bits)
+{
PlaneContext * const p= &s->plane[plane_index];
RangeCoder * const c= &s->c;
int x;
@@ -592,7 +598,7 @@ static av_always_inline int encode_line(FFV1Context *s, int w, int_fast16_t *sam
static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){
int x,y,i;
const int ring_size= s->avctx->context_model ? 3 : 2;
- int_fast16_t *sample[3];
+ int16_t *sample[3];
s->run_index=0;
memset(s->sample_buffer, 0, ring_size*(w+6)*sizeof(*s->sample_buffer));
@@ -628,7 +634,7 @@ static void encode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride,
static void encode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){
int x, y, p, i;
const int ring_size= s->avctx->context_model ? 3 : 2;
- int_fast16_t *sample[3][3];
+ int16_t *sample[3][3];
s->run_index=0;
memset(s->sample_buffer, 0, ring_size*3*(w+6)*sizeof(*s->sample_buffer));
@@ -1318,7 +1324,10 @@ static av_cold int common_end(AVCodecContext *avctx){
return 0;
}
-static av_always_inline void decode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
+static av_always_inline void decode_line(FFV1Context *s, int w,
+ int16_t *sample[2],
+ int plane_index, int bits)
+{
PlaneContext * const p= &s->plane[plane_index];
RangeCoder * const c= &s->c;
int x;
@@ -1378,7 +1387,7 @@ static av_always_inline void decode_line(FFV1Context *s, int w, int_fast16_t *sa
static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride, int plane_index){
int x, y;
- int_fast16_t *sample[2];
+ int16_t *sample[2];
sample[0]=s->sample_buffer +3;
sample[1]=s->sample_buffer+w+6+3;
@@ -1387,7 +1396,7 @@ static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride,
memset(s->sample_buffer, 0, 2*(w+6)*sizeof(*s->sample_buffer));
for(y=0; y<h; y++){
- int_fast16_t *temp= sample[0]; //FIXME try a normal buffer
+ int16_t *temp = sample[0]; //FIXME try a normal buffer
sample[0]= sample[1];
sample[1]= temp;
@@ -1419,7 +1428,7 @@ static void decode_plane(FFV1Context *s, uint8_t *src, int w, int h, int stride,
static void decode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int stride){
int x, y, p;
- int_fast16_t *sample[3][2];
+ int16_t *sample[3][2];
for(x=0; x<3; x++){
sample[x][0] = s->sample_buffer + x*2 *(w+6) + 3;
sample[x][1] = s->sample_buffer + (x*2+1)*(w+6) + 3;
@@ -1431,7 +1440,7 @@ static void decode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int st
for(y=0; y<h; y++){
for(p=0; p<3; p++){
- int_fast16_t *temp= sample[p][0]; //FIXME try a normal buffer
+ int16_t *temp = sample[p][0]; //FIXME try a normal buffer
sample[p][0]= sample[p][1];
sample[p][1]= temp;
diff --git a/libavcodec/jfdctfst.c b/libavcodec/jfdctfst.c
index b911909ec3..8d3448a676 100644
--- a/libavcodec/jfdctfst.c
+++ b/libavcodec/jfdctfst.c
@@ -145,9 +145,9 @@
#define MULTIPLY(var,const) ((DCTELEM) DESCALE((var) * (const), CONST_BITS))
static av_always_inline void row_fdct(DCTELEM * data){
- int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast16_t tmp10, tmp11, tmp12, tmp13;
- int_fast16_t z1, z2, z3, z4, z5, z11, z13;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1, z2, z3, z4, z5, z11, z13;
DCTELEM *dataptr;
int ctr;
@@ -209,9 +209,9 @@ static av_always_inline void row_fdct(DCTELEM * data){
GLOBAL(void)
fdct_ifast (DCTELEM * data)
{
- int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast16_t tmp10, tmp11, tmp12, tmp13;
- int_fast16_t z1, z2, z3, z4, z5, z11, z13;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1, z2, z3, z4, z5, z11, z13;
DCTELEM *dataptr;
int ctr;
@@ -275,9 +275,9 @@ fdct_ifast (DCTELEM * data)
GLOBAL(void)
fdct_ifast248 (DCTELEM * data)
{
- int_fast16_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast16_t tmp10, tmp11, tmp12, tmp13;
- int_fast16_t z1;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1;
DCTELEM *dataptr;
int ctr;
diff --git a/libavcodec/jfdctint.c b/libavcodec/jfdctint.c
index f6e8c4e939..072c7440b5 100644
--- a/libavcodec/jfdctint.c
+++ b/libavcodec/jfdctint.c
@@ -181,9 +181,9 @@
static av_always_inline void row_fdct(DCTELEM * data){
- int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast32_t tmp10, tmp11, tmp12, tmp13;
- int_fast32_t z1, z2, z3, z4, z5;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1, z2, z3, z4, z5;
DCTELEM *dataptr;
int ctr;
@@ -259,9 +259,9 @@ static av_always_inline void row_fdct(DCTELEM * data){
GLOBAL(void)
ff_jpeg_fdct_islow (DCTELEM * data)
{
- int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast32_t tmp10, tmp11, tmp12, tmp13;
- int_fast32_t z1, z2, z3, z4, z5;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1, z2, z3, z4, z5;
DCTELEM *dataptr;
int ctr;
@@ -345,9 +345,9 @@ ff_jpeg_fdct_islow (DCTELEM * data)
GLOBAL(void)
ff_fdct248_islow (DCTELEM * data)
{
- int_fast32_t tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
- int_fast32_t tmp10, tmp11, tmp12, tmp13;
- int_fast32_t z1;
+ int tmp0, tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7;
+ int tmp10, tmp11, tmp12, tmp13;
+ int z1;
DCTELEM *dataptr;
int ctr;
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 768dbfe6f9..9b5c17c59d 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -25,9 +25,6 @@
* @author Adam Thayer (krevnik@comcast.net)
*/
-/* needed for mkstemp() */
-#define _XOPEN_SOURCE 600
-
#include <xvid.h>
#include <unistd.h>
#include "avcodec.h"
diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c
index 7e7ae0f007..587ddc604f 100644
--- a/libavcodec/tiff.c
+++ b/libavcodec/tiff.c
@@ -38,7 +38,7 @@ typedef struct TiffContext {
AVFrame picture;
int width, height;
- unsigned int bpp;
+ unsigned int bpp, bppcount;
int le;
enum TiffCompr compr;
int invert;
@@ -214,6 +214,55 @@ static int tiff_unpack_strip(TiffContext *s, uint8_t* dst, int stride, const uin
return 0;
}
+static int init_image(TiffContext *s)
+{
+ int i, ret;
+ uint32_t *pal;
+
+ switch (s->bpp * 10 + s->bppcount) {
+ case 11:
+ s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
+ break;
+ case 81:
+ s->avctx->pix_fmt = PIX_FMT_PAL8;
+ break;
+ case 243:
+ s->avctx->pix_fmt = PIX_FMT_RGB24;
+ break;
+ case 161:
+ s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
+ break;
+ case 324:
+ s->avctx->pix_fmt = PIX_FMT_RGBA;
+ break;
+ case 483:
+ s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
+ break;
+ default:
+ av_log(s->avctx, AV_LOG_ERROR,
+ "This format is not supported (bpp=%d, bppcount=%d)\n",
+ s->bpp, s->bppcount);
+ return AVERROR_INVALIDDATA;
+ }
+ if (s->width != s->avctx->width || s->height != s->avctx->height) {
+ if ((ret = av_image_check_size(s->width, s->height, 0, s->avctx)) < 0)
+ return ret;
+ avcodec_set_dimensions(s->avctx, s->width, s->height);
+ }
+ if (s->picture.data[0])
+ s->avctx->release_buffer(s->avctx, &s->picture);
+ if ((ret = s->avctx->get_buffer(s->avctx, &s->picture)) < 0) {
+ av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
+ return ret;
+ }
+ if (s->bpp == 8 && s->picture.data[1]){
+ /* make default grayscale pal */
+ pal = (uint32_t *) s->picture.data[1];
+ for (i = 0; i < 256; i++)
+ pal[i] = i * 0x010101;
+ }
+ return 0;
+}
static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *buf, const uint8_t *end_buf)
{
@@ -267,6 +316,7 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->height = value;
break;
case TIFF_BPP:
+ s->bppcount = count;
if(count > 4){
av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
return -1;
@@ -286,46 +336,16 @@ static int tiff_decode_tag(TiffContext *s, const uint8_t *start, const uint8_t *
s->bpp = -1;
}
}
- switch(s->bpp*10 + count){
- case 11:
- s->avctx->pix_fmt = PIX_FMT_MONOBLACK;
- break;
- case 81:
- s->avctx->pix_fmt = PIX_FMT_PAL8;
- break;
- case 243:
- s->avctx->pix_fmt = PIX_FMT_RGB24;
- break;
- case 161:
- s->avctx->pix_fmt = PIX_FMT_GRAY16BE;
- break;
- case 324:
- s->avctx->pix_fmt = PIX_FMT_RGBA;
- break;
- case 483:
- s->avctx->pix_fmt = s->le ? PIX_FMT_RGB48LE : PIX_FMT_RGB48BE;
- break;
- default:
- av_log(s->avctx, AV_LOG_ERROR, "This format is not supported (bpp=%d, %d components)\n", s->bpp, count);
- return -1;
- }
- if(s->width != s->avctx->width || s->height != s->avctx->height){
- if(av_image_check_size(s->width, s->height, 0, s->avctx))
- return -1;
- avcodec_set_dimensions(s->avctx, s->width, s->height);
- }
- if(s->picture.data[0])
- s->avctx->release_buffer(s->avctx, &s->picture);
- if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
- if(s->bpp == 8){
- /* make default grayscale pal */
- pal = (uint32_t *) s->picture.data[1];
- for(i = 0; i < 256; i++)
- pal[i] = i * 0x010101;
- }
+ break;
+ case TIFF_SAMPLES_PER_PIXEL:
+ if (count != 1) {
+ av_log(s->avctx, AV_LOG_ERROR,
+ "Samples per pixel requires a single value, many provided\n");
+ return AVERROR_INVALIDDATA;
+ }
+ if (s->bppcount == 1)
+ s->bpp *= value;
+ s->bppcount = value;
break;
case TIFF_COMPR:
s->compr = value;
@@ -468,7 +488,7 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame *picture = data;
AVFrame * const p= (AVFrame*)&s->picture;
const uint8_t *orig_buf = buf, *end_buf = buf + buf_size;
- int id, le, off;
+ int id, le, off, ret;
int i, j, entries;
int stride, soff, ssize;
uint8_t *dst;
@@ -509,21 +529,9 @@ static int decode_frame(AVCodecContext *avctx,
return -1;
}
/* now we have the data and may start decoding */
- if(!p->data[0]){
- s->bpp = 1;
- avctx->pix_fmt = PIX_FMT_MONOBLACK;
- if(s->width != s->avctx->width || s->height != s->avctx->height){
- if(av_image_check_size(s->width, s->height, 0, s->avctx))
- return -1;
- avcodec_set_dimensions(s->avctx, s->width, s->height);
- }
- if(s->picture.data[0])
- s->avctx->release_buffer(s->avctx, &s->picture);
- if(s->avctx->get_buffer(s->avctx, &s->picture) < 0){
- av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
- return -1;
- }
- }
+ if ((ret = init_image(s)) < 0)
+ return ret;
+
if(s->strips == 1 && !s->stripsize){
av_log(avctx, AV_LOG_WARNING, "Image data size missing\n");
s->stripsize = buf_size - s->stripoff;
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index 68acc77ab9..a805452eab 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -53,9 +53,7 @@ unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n)
// reasonable to check redundantly.
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
{
- uint_fast32_t exit_at_level[33] = {
- 404, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+ uint32_t exit_at_level[33] = { 404 };
unsigned i, j, p, code;
@@ -106,7 +104,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
#ifdef V_DEBUG
av_log(NULL, AV_LOG_INFO, " %d. code len %d code %d - ", p, bits[p], codes[p]);
- init_get_bits(&gb, (uint_fast8_t *)&codes[p], bits[p]);
+ init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
for (i = 0; i < bits[p]; ++i)
av_log(NULL, AV_LOG_INFO, "%s", get_bits1(&gb) ? "1" : "0");
av_log(NULL, AV_LOG_INFO, "\n");
@@ -206,7 +204,7 @@ static void render_line(int x0, int y0, int x1, int y1, float *buf)
}
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
- uint_fast16_t *y_list, int *flag,
+ uint16_t *y_list, int *flag,
int multiplier, float *out, int samples)
{
int lx, ly, i;
diff --git a/libavcodec/vorbis.h b/libavcodec/vorbis.h
index 28c1bcf636..15b5d85b36 100644
--- a/libavcodec/vorbis.h
+++ b/libavcodec/vorbis.h
@@ -30,17 +30,17 @@ extern const uint8_t ff_vorbis_encoding_channel_layout_offsets[8][8];
extern const int64_t ff_vorbis_channel_layouts[9];
typedef struct {
- uint_fast16_t x;
- uint_fast16_t sort;
- uint_fast16_t low;
- uint_fast16_t high;
+ uint16_t x;
+ uint16_t sort;
+ uint16_t low;
+ uint16_t high;
} vorbis_floor1_entry;
void ff_vorbis_ready_floor1_list(vorbis_floor1_entry * list, int values);
unsigned int ff_vorbis_nth_root(unsigned int x, unsigned int n); // x^(1/n)
int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num);
void ff_vorbis_floor1_render_list(vorbis_floor1_entry * list, int values,
- uint_fast16_t * y_list, int * flag,
+ uint16_t *y_list, int *flag,
int multiplier, float * out, int samples);
void vorbis_inverse_coupling(float *mag, float *ang, int blocksize);
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index 161c54d6bc..f4b743e8ab 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -49,11 +49,11 @@
#include <assert.h>
typedef struct {
- uint_fast8_t dimensions;
- uint_fast8_t lookup_type;
- uint_fast8_t maxdepth;
- VLC vlc;
- float *codevectors;
+ uint8_t dimensions;
+ uint8_t lookup_type;
+ uint8_t maxdepth;
+ VLC vlc;
+ float *codevectors;
unsigned int nb_bits;
} vorbis_codebook;
@@ -65,63 +65,63 @@ typedef
int (* vorbis_floor_decode_func)
(struct vorbis_context_s *, vorbis_floor_data *, float *);
typedef struct {
- uint_fast8_t floor_type;
+ uint8_t floor_type;
vorbis_floor_decode_func decode;
union vorbis_floor_u {
struct vorbis_floor0_s {
- uint_fast8_t order;
- uint_fast16_t rate;
- uint_fast16_t bark_map_size;
- int_fast32_t *map[2];
- uint_fast32_t map_size[2];
- uint_fast8_t amplitude_bits;
- uint_fast8_t amplitude_offset;
- uint_fast8_t num_books;
- uint_fast8_t *book_list;
+ uint8_t order;
+ uint16_t rate;
+ uint16_t bark_map_size;
+ int32_t *map[2];
+ uint32_t map_size[2];
+ uint8_t amplitude_bits;
+ uint8_t amplitude_offset;
+ uint8_t num_books;
+ uint8_t *book_list;
float *lsp;
} t0;
struct vorbis_floor1_s {
- uint_fast8_t partitions;
- uint8_t partition_class[32];
- uint_fast8_t class_dimensions[16];
- uint_fast8_t class_subclasses[16];
- uint_fast8_t class_masterbook[16];
- int_fast16_t subclass_books[16][8];
- uint_fast8_t multiplier;
- uint_fast16_t x_list_dim;
+ uint8_t partitions;
+ uint8_t partition_class[32];
+ uint8_t class_dimensions[16];
+ uint8_t class_subclasses[16];
+ uint8_t class_masterbook[16];
+ int16_t subclass_books[16][8];
+ uint8_t multiplier;
+ uint16_t x_list_dim;
vorbis_floor1_entry *list;
} t1;
} data;
} vorbis_floor;
typedef struct {
- uint_fast16_t type;
- uint_fast32_t begin;
- uint_fast32_t end;
+ uint16_t type;
+ uint32_t begin;
+ uint32_t end;
unsigned partition_size;
- uint_fast8_t classifications;
- uint_fast8_t classbook;
- int_fast16_t books[64][8];
- uint_fast8_t maxpass;
- uint_fast16_t ptns_to_read;
- uint8_t *classifs;
+ uint8_t classifications;
+ uint8_t classbook;
+ int16_t books[64][8];
+ uint8_t maxpass;
+ uint16_t ptns_to_read;
+ uint8_t *classifs;
} vorbis_residue;
typedef struct {
- uint_fast8_t submaps;
- uint_fast16_t coupling_steps;
- uint_fast8_t *magnitude;
- uint_fast8_t *angle;
- uint_fast8_t *mux;
- uint_fast8_t submap_floor[16];
- uint_fast8_t submap_residue[16];
+ uint8_t submaps;
+ uint16_t coupling_steps;
+ uint8_t *magnitude;
+ uint8_t *angle;
+ uint8_t *mux;
+ uint8_t submap_floor[16];
+ uint8_t submap_residue[16];
} vorbis_mapping;
typedef struct {
- uint_fast8_t blockflag;
- uint_fast16_t windowtype;
- uint_fast16_t transformtype;
- uint_fast8_t mapping;
+ uint8_t blockflag;
+ uint16_t windowtype;
+ uint16_t transformtype;
+ uint8_t mapping;
} vorbis_mode;
typedef struct vorbis_context_s {
@@ -131,27 +131,27 @@ typedef struct vorbis_context_s {
FmtConvertContext fmt_conv;
FFTContext mdct[2];
- uint_fast8_t first_frame;
- uint_fast32_t version;
- uint_fast8_t audio_channels;
- uint_fast32_t audio_samplerate;
- uint_fast32_t bitrate_maximum;
- uint_fast32_t bitrate_nominal;
- uint_fast32_t bitrate_minimum;
- uint_fast32_t blocksize[2];
+ uint8_t first_frame;
+ uint32_t version;
+ uint8_t audio_channels;
+ uint32_t audio_samplerate;
+ uint32_t bitrate_maximum;
+ uint32_t bitrate_nominal;
+ uint32_t bitrate_minimum;
+ uint32_t blocksize[2];
const float *win[2];
- uint_fast16_t codebook_count;
+ uint16_t codebook_count;
vorbis_codebook *codebooks;
- uint_fast8_t floor_count;
+ uint8_t floor_count;
vorbis_floor *floors;
- uint_fast8_t residue_count;
+ uint8_t residue_count;
vorbis_residue *residues;
- uint_fast8_t mapping_count;
+ uint8_t mapping_count;
vorbis_mapping *mappings;
- uint_fast8_t mode_count;
+ uint8_t mode_count;
vorbis_mode *modes;
- uint_fast8_t mode_number; // mode number for the current packet
- uint_fast8_t previous_window;
+ uint8_t mode_number; // mode number for the current packet
+ uint8_t previous_window;
float *channel_residues;
float *channel_floors;
float *saved;
@@ -241,7 +241,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
uint8_t *tmp_vlc_bits;
uint32_t *tmp_vlc_codes;
GetBitContext *gb = &vc->gb;
- uint_fast16_t *codebook_multiplicands;
+ uint16_t *codebook_multiplicands;
vc->codebook_count = get_bits(gb, 8) + 1;
@@ -359,7 +359,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
codebook_multiplicands[i] = get_bits(gb, codebook_value_bits);
AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value);
- AV_DEBUG(" multiplicand %d \n", codebook_multiplicands[i]);
+ AV_DEBUG(" multiplicand %u\n", codebook_multiplicands[i]);
}
// Weed out unused vlcs and build codevector vector
@@ -544,7 +544,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
rangemax = (1 << rangebits);
if (rangemax > vc->blocksize[1] / 2) {
av_log(vc->avccontext, AV_LOG_ERROR,
- "Floor value is too large for blocksize: %u (%"PRIuFAST32")\n",
+ "Floor value is too large for blocksize: %u (%"PRIu32")\n",
rangemax, vc->blocksize[1] / 2);
return -1;
}
@@ -652,7 +652,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
for (i = 0; i < vc->residue_count; ++i) {
vorbis_residue *res_setup = &vc->residues[i];
- uint_fast8_t cascade[64];
+ uint8_t cascade[64];
unsigned high_bits, low_bits;
res_setup->type = get_bits(gb, 16);
@@ -666,7 +666,10 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
if (res_setup->begin>res_setup->end ||
res_setup->end > vc->avccontext->channels * vc->blocksize[1] / 2 ||
(res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) {
- av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIdFAST16", %"PRIdFAST32", %"PRIdFAST32", %u, %"PRIdFAST32"\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1] / 2);
+ av_log(vc->avccontext, AV_LOG_ERROR,
+ "partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n",
+ res_setup->type, res_setup->begin, res_setup->end,
+ res_setup->partition_size, vc->blocksize[1] / 2);
return -1;
}
@@ -790,12 +793,12 @@ static void create_map(vorbis_context *vc, unsigned floor_number)
vorbis_floor0 *vf;
int idx;
int blockflag, n;
- int_fast32_t *map;
+ int32_t *map;
for (blockflag = 0; blockflag < 2; ++blockflag) {
n = vc->blocksize[blockflag] / 2;
floors[floor_number].data.t0.map[blockflag] =
- av_malloc((n+1) * sizeof(int_fast32_t)); // n + sentinel
+ av_malloc((n + 1) * sizeof(int32_t)); // n + sentinel
map = floors[floor_number].data.t0.map[blockflag];
vf = &floors[floor_number].data.t0;
@@ -1145,10 +1148,10 @@ static int vorbis_floor1_decode(vorbis_context *vc,
{
vorbis_floor1 *vf = &vfu->t1;
GetBitContext *gb = &vc->gb;
- uint_fast16_t range_v[4] = { 256, 128, 86, 64 };
- unsigned range = range_v[vf->multiplier-1];
- uint_fast16_t floor1_Y[258];
- uint_fast16_t floor1_Y_final[258];
+ uint16_t range_v[4] = { 256, 128, 86, 64 };
+ unsigned range = range_v[vf->multiplier - 1];
+ uint16_t floor1_Y[258];
+ uint16_t floor1_Y_final[258];
int floor1_flag[258];
unsigned partition_class, cdim, cbits, csub, cval, offset, i, j;
int book, adx, ady, dy, off, predicted, err;
@@ -1250,7 +1253,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y_final[i] = predicted;
}
- AV_DEBUG(" Decoded floor(%d) = %d / val %u\n",
+ AV_DEBUG(" Decoded floor(%d) = %u / val %u\n",
vf->list[i].x, floor1_Y_final[i], val);
}
@@ -1268,7 +1271,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
vorbis_residue *vr,
unsigned ch,
- uint_fast8_t *do_not_decode,
+ uint8_t *do_not_decode,
float *vec,
unsigned vlen,
int vr_type)
@@ -1405,7 +1408,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
static inline int vorbis_residue_decode(vorbis_context *vc, vorbis_residue *vr,
unsigned ch,
- uint_fast8_t *do_not_decode,
+ uint8_t *do_not_decode,
float *vec, unsigned vlen)
{
if (vr->type == 2)
@@ -1453,12 +1456,12 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
unsigned previous_window = vc->previous_window;
unsigned mode_number, blockflag, blocksize;
int i, j;
- uint_fast8_t no_residue[255];
- uint_fast8_t do_not_decode[255];
+ uint8_t no_residue[255];
+ uint8_t do_not_decode[255];
vorbis_mapping *mapping;
float *ch_res_ptr = vc->channel_residues;
float *ch_floor_ptr = vc->channel_floors;
- uint_fast8_t res_chan[255];
+ uint8_t res_chan[255];
unsigned res_num = 0;
int retlen = 0;
diff --git a/libavcodec/vorbisenc.c b/libavcodec/vorbisenc.c
index d15d3454eb..617e2b7cc4 100644
--- a/libavcodec/vorbisenc.c
+++ b/libavcodec/vorbisenc.c
@@ -674,7 +674,7 @@ static float get_floor_average(vorbis_enc_floor * fc, float *coeffs, int i)
}
static void floor_fit(vorbis_enc_context *venc, vorbis_enc_floor *fc,
- float *coeffs, uint_fast16_t *posts, int samples)
+ float *coeffs, uint16_t *posts, int samples)
{
int range = 255 / fc->multiplier + 1;
int i;
@@ -706,7 +706,7 @@ static int render_point(int x0, int y0, int x1, int y1, int x)
}
static void floor_encode(vorbis_enc_context *venc, vorbis_enc_floor *fc,
- PutBitContext *pb, uint_fast16_t *posts,
+ PutBitContext *pb, uint16_t *posts,
float *floor, int samples)
{
int range = 255 / fc->multiplier + 1;
@@ -1010,7 +1010,7 @@ static int vorbis_encode_frame(AVCodecContext *avccontext,
for (i = 0; i < venc->channels; i++) {
vorbis_enc_floor *fc = &venc->floors[mapping->floor[mapping->mux[i]]];
- uint_fast16_t posts[MAX_FLOOR_VALUES];
+ uint16_t posts[MAX_FLOOR_VALUES];
floor_fit(venc, fc, &venc->coeffs[i * samples], posts, samples);
floor_encode(venc, fc, &pb, posts, &venc->floor[i * samples], samples);
}