From c8f487deae75d4f25c2ec39ab484c1075f909bbd Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Wed, 11 May 2011 19:15:14 -0400 Subject: [PATCH 01/33] swscale: fix YUV420P 9/10bit support. Fix handling of input if not in native endianness, and add support for 9/10-bit output. This allows us to force endianness of YUV420P 9/10bit in the H264/10bit fate tests, which should fix them on big-endian systems. --- libavutil/pixfmt.h | 4 +- libswscale/ppc/swscale_template.c | 4 +- libswscale/swscale.c | 175 ++++++++++++++++++++++++------ libswscale/swscale_internal.h | 2 +- libswscale/swscale_template.c | 40 ++++--- libswscale/utils.c | 4 + libswscale/x86/swscale_template.c | 4 +- tests/fate/h264.mak | 14 +-- tests/ref/lavfi/pixdesc_le | 4 + tests/ref/lavfi/pixfmts_copy_le | 4 + tests/ref/lavfi/pixfmts_null_le | 4 + tests/ref/lavfi/pixfmts_scale_le | 4 + tests/ref/lavfi/pixfmts_vflip_le | 4 + 13 files changed, 202 insertions(+), 65 deletions(-) diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 533eb9f706..d88775f462 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -128,10 +128,10 @@ enum PixelFormat { PIX_FMT_VDPAU_MPEG4, ///< MPEG4 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers PIX_FMT_DXVA2_VLD, ///< HW decoding through DXVA2, Picture.data[3] contains a LPDIRECT3DSURFACE9 pointer - PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 PIX_FMT_RGB444LE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), little-endian, most significant bits to 0 - PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 + PIX_FMT_RGB444BE, ///< packed RGB 4:4:4, 16bpp, (msb)4A 4R 4G 4B(lsb), big-endian, most significant bits to 0 PIX_FMT_BGR444LE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), little-endian, most significant bits to 1 + PIX_FMT_BGR444BE, ///< packed BGR 4:4:4, 16bpp, (msb)4A 4B 4G 4R(lsb), big-endian, most significant bits to 1 PIX_FMT_Y400A, ///< 8bit gray, 8bit alpha PIX_FMT_BGR48BE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as big-endian PIX_FMT_BGR48LE, ///< packed RGB 16:16:16, 48bpp, 16B, 16G, 16R, the 2-byte value for each R/G/B component is stored as little-endian diff --git a/libswscale/ppc/swscale_template.c b/libswscale/ppc/swscale_template.c index 3e40c3f0a6..e69656ca15 100644 --- a/libswscale/ppc/swscale_template.c +++ b/libswscale/ppc/swscale_template.c @@ -639,7 +639,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, @@ -716,7 +716,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 2830f26ce5..b63a3868c5 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -212,10 +212,11 @@ DECLARE_ALIGNED(8, const uint8_t, dither_8x8_220)[8][8]={ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrSrc, int chrFilterSize, const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, - int dstW, int chrDstW, int big_endian) + int dstW, int chrDstW, int big_endian, int output_bits) { //FIXME Optimize (just quickly written not optimized..) int i; + int shift = 11 + 16 - output_bits; for (i = 0; i < dstW; i++) { int val = 1 << 10; @@ -225,9 +226,9 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co val += lumSrc[j][i] * lumFilter[j]; if (big_endian) { - AV_WB16(&dest[i], av_clip_uint16(val >> 11)); + AV_WB16(&dest[i], av_clip_uint16(val >> shift)); } else { - AV_WL16(&dest[i], av_clip_uint16(val >> 11)); + AV_WL16(&dest[i], av_clip_uint16(val >> shift)); } } @@ -243,11 +244,11 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co } if (big_endian) { - AV_WB16(&uDest[i], av_clip_uint16(u >> 11)); - AV_WB16(&vDest[i], av_clip_uint16(v >> 11)); + AV_WB16(&uDest[i], av_clip_uint16(u >> shift)); + AV_WB16(&vDest[i], av_clip_uint16(v >> shift)); } else { - AV_WL16(&uDest[i], av_clip_uint16(u >> 11)); - AV_WL16(&vDest[i], av_clip_uint16(v >> 11)); + AV_WL16(&uDest[i], av_clip_uint16(u >> shift)); + AV_WL16(&vDest[i], av_clip_uint16(v >> shift)); } } } @@ -261,9 +262,9 @@ static av_always_inline void yuv2yuvX16inC_template(const int16_t *lumFilter, co val += alpSrc[j][i] * lumFilter[j]; if (big_endian) { - AV_WB16(&aDest[i], av_clip_uint16(val >> 11)); + AV_WB16(&aDest[i], av_clip_uint16(val >> shift)); } else { - AV_WL16(&aDest[i], av_clip_uint16(val >> 11)); + AV_WL16(&aDest[i], av_clip_uint16(val >> shift)); } } } @@ -274,19 +275,28 @@ static inline void yuv2yuvX16inC(const int16_t *lumFilter, const int16_t **lumSr const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, enum PixelFormat dstFormat) { - if (isBE(dstFormat)) { - yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize, - chrFilter, chrSrc, chrFilterSize, - alpSrc, - dest, uDest, vDest, aDest, - dstW, chrDstW, 1); +#define conv16(bits) \ + if (isBE(dstFormat)) { \ + yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrSrc, chrFilterSize, \ + alpSrc, \ + dest, uDest, vDest, aDest, \ + dstW, chrDstW, 1, bits); \ + } else { \ + yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrSrc, chrFilterSize, \ + alpSrc, \ + dest, uDest, vDest, aDest, \ + dstW, chrDstW, 0, bits); \ + } + if (is16BPS(dstFormat)) { + conv16(16); + } else if (av_pix_fmt_descriptors[dstFormat].comp[0].depth_minus1 == 8) { + conv16(9); } else { - yuv2yuvX16inC_template(lumFilter, lumSrc, lumFilterSize, - chrFilter, chrSrc, chrFilterSize, - alpSrc, - dest, uDest, vDest, aDest, - dstW, chrDstW, 0); + conv16(10); } +#undef conv16 } static inline void yuv2yuvXinC(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, @@ -1669,25 +1679,124 @@ static int planarCopyWrapper(SwsContext *c, const uint8_t* src[], int srcStride[ length*=2; fillPlane(dst[plane], dstStride[plane], length, height, y, (plane==3) ? 255 : 128); } else { - if(isNBPS(c->srcFormat)) { - const int depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1; - uint16_t *srcPtr2 = (uint16_t*)srcPtr; + if(is9_OR_10BPS(c->srcFormat)) { + const int src_depth = av_pix_fmt_descriptors[c->srcFormat].comp[plane].depth_minus1+1; + const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1; + const uint16_t *srcPtr2 = (const uint16_t*)srcPtr; if (is16BPS(c->dstFormat)) { uint16_t *dstPtr2 = (uint16_t*)dstPtr; - for (i = 0; i < height; i++) { - for (j = 0; j < length; j++) - dstPtr2[j] = (srcPtr2[j]<<(16-depth)) | (srcPtr2[j]>>(2*depth-16)); - dstPtr2 += dstStride[plane]/2; - srcPtr2 += srcStride[plane]/2; +#define COPY9_OR_10TO16(rfunc, wfunc) \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < length; j++) { \ + int srcpx = rfunc(&srcPtr2[j]); \ + wfunc(&dstPtr2[j], (srcpx<<(16-src_depth)) | (srcpx>>(2*src_depth-16))); \ + } \ + dstPtr2 += dstStride[plane]/2; \ + srcPtr2 += srcStride[plane]/2; \ + } + if (isBE(c->dstFormat)) { + if (isBE(c->srcFormat)) { + COPY9_OR_10TO16(AV_RB16, AV_WB16); + } else { + COPY9_OR_10TO16(AV_RL16, AV_WB16); + } + } else { + if (isBE(c->srcFormat)) { + COPY9_OR_10TO16(AV_RB16, AV_WL16); + } else { + COPY9_OR_10TO16(AV_RL16, AV_WL16); + } + } + } else if (is9_OR_10BPS(c->dstFormat)) { + uint16_t *dstPtr2 = (uint16_t*)dstPtr; +#define COPY9_OR_10TO9_OR_10(loop) \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < length; j++) { \ + loop; \ + } \ + dstPtr2 += dstStride[plane]/2; \ + srcPtr2 += srcStride[plane]/2; \ + } +#define COPY9_OR_10TO9_OR_10_2(rfunc, wfunc) \ + if (dst_depth > src_depth) { \ + COPY9_OR_10TO9_OR_10(int srcpx = rfunc(&srcPtr2[j]); \ + wfunc(&dstPtr2[j], (srcpx << 1) | (srcpx >> 9))); \ + } else if (dst_depth < src_depth) { \ + COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]) >> 1)); \ + } else { \ + COPY9_OR_10TO9_OR_10(wfunc(&dstPtr2[j], rfunc(&srcPtr2[j]))); \ + } + if (isBE(c->dstFormat)) { + if (isBE(c->srcFormat)) { + COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WB16); + } else { + COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WB16); + } + } else { + if (isBE(c->srcFormat)) { + COPY9_OR_10TO9_OR_10_2(AV_RB16, AV_WL16); + } else { + COPY9_OR_10TO9_OR_10_2(AV_RL16, AV_WL16); + } } } else { // FIXME Maybe dither instead. - for (i = 0; i < height; i++) { - for (j = 0; j < length; j++) - dstPtr[j] = srcPtr2[j]>>(depth-8); - dstPtr += dstStride[plane]; - srcPtr2 += srcStride[plane]/2; +#define COPY9_OR_10TO8(rfunc) \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < length; j++) { \ + dstPtr[j] = rfunc(&srcPtr2[j])>>(src_depth-8); \ + } \ + dstPtr += dstStride[plane]; \ + srcPtr2 += srcStride[plane]/2; \ + } + if (isBE(c->srcFormat)) { + COPY9_OR_10TO8(AV_RB16); + } else { + COPY9_OR_10TO8(AV_RL16); + } + } + } else if(is9_OR_10BPS(c->dstFormat)) { + const int dst_depth = av_pix_fmt_descriptors[c->dstFormat].comp[plane].depth_minus1+1; + uint16_t *dstPtr2 = (uint16_t*)dstPtr; + + if (is16BPS(c->srcFormat)) { + const uint16_t *srcPtr2 = (const uint16_t*)srcPtr; +#define COPY16TO9_OR_10(rfunc, wfunc) \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < length; j++) { \ + wfunc(&dstPtr2[j], rfunc(&srcPtr2[j])>>(16-dst_depth)); \ + } \ + dstPtr2 += dstStride[plane]/2; \ + srcPtr2 += srcStride[plane]/2; \ + } + if (isBE(c->dstFormat)) { + if (isBE(c->srcFormat)) { + COPY16TO9_OR_10(AV_RB16, AV_WB16); + } else { + COPY16TO9_OR_10(AV_RL16, AV_WB16); + } + } else { + if (isBE(c->srcFormat)) { + COPY16TO9_OR_10(AV_RB16, AV_WL16); + } else { + COPY16TO9_OR_10(AV_RL16, AV_WL16); + } + } + } else /* 8bit */ { +#define COPY8TO9_OR_10(wfunc) \ + for (i = 0; i < height; i++) { \ + for (j = 0; j < length; j++) { \ + const int srcpx = srcPtr[j]; \ + wfunc(&dstPtr2[j], (srcpx<<(dst_depth-8)) | (srcpx >> (16-dst_depth))); \ + } \ + dstPtr2 += dstStride[plane]/2; \ + srcPtr += srcStride[plane]; \ + } + if (isBE(c->dstFormat)) { + COPY8TO9_OR_10(AV_WB16); + } else { + COPY8TO9_OR_10(AV_WL16); } } } else if(is16BPS(c->srcFormat) && !is16BPS(c->dstFormat)) { diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 2d40215ea9..2369546cb7 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -354,7 +354,7 @@ const char *sws_format_name(enum PixelFormat format); || (x)==PIX_FMT_YUV422P16BE \ || (x)==PIX_FMT_YUV444P16BE \ ) -#define isNBPS(x) ( \ +#define is9_OR_10BPS(x) ( \ (x)==PIX_FMT_YUV420P9LE \ || (x)==PIX_FMT_YUV420P9BE \ || (x)==PIX_FMT_YUV420P10LE \ diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c index 81a8d66277..fe872561cb 100644 --- a/libswscale/swscale_template.c +++ b/libswscale/swscale_template.c @@ -164,6 +164,8 @@ static inline void LEToUV_c(uint8_t *dstU, uint8_t *dstV, const uint8_t *src1, const uint8_t *src2, long width, uint32_t *unused) { int i; + // FIXME I don't think this code is right for YUV444/422, since then h is not subsampled so + // we need to skip each second pixel. Same for BEToUV. for (i=0; i>(depth-8); \ - dstV[i] = srcV[i]>>(depth-8); \ + dstU[i] = rfunc(&srcU[i])>>(depth-8); \ + dstV[i] = rfunc(&srcV[i])>>(depth-8); \ } \ } \ \ -static inline void yuv ## depth ## ToY_c(uint8_t *dstY, const uint8_t *_srcY, long width, uint32_t *unused) \ +static inline void endianness ## depth ## ToY_c(uint8_t *dstY, const uint8_t *_srcY, long width, uint32_t *unused) \ { \ int i; \ const uint16_t *srcY = (const uint16_t*)_srcY; \ for (i = 0; i < width; i++) \ - dstY[i] = srcY[i]>>(depth-8); \ + dstY[i] = rfunc(&srcY[i])>>(depth-8); \ } \ -YUV_NBPS( 9) -YUV_NBPS(10) +YUV_NBPS( 9, LE, AV_RL16) +YUV_NBPS( 9, BE, AV_RB16) +YUV_NBPS(10, LE, AV_RL16) +YUV_NBPS(10, BE, AV_RB16) static inline void bgr24ToY_c(uint8_t *dst, const uint8_t *src, long width, uint32_t *unused) @@ -666,7 +670,7 @@ static int swScale_c(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, @@ -743,7 +747,7 @@ static int swScale_c(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, @@ -816,10 +820,10 @@ static void sws_init_swScale_c(SwsContext *c) case PIX_FMT_PAL8 : case PIX_FMT_BGR4_BYTE: case PIX_FMT_RGB4_BYTE: c->chrToYV12 = palToUV; break; - case PIX_FMT_YUV420P9BE: - case PIX_FMT_YUV420P9LE: c->chrToYV12 = yuv9ToUV_c; break; - case PIX_FMT_YUV420P10BE: - case PIX_FMT_YUV420P10LE: c->chrToYV12 = yuv10ToUV_c; break; + case PIX_FMT_YUV420P9BE: c->chrToYV12 = BE9ToUV_c; break; + case PIX_FMT_YUV420P9LE: c->chrToYV12 = LE9ToUV_c; break; + case PIX_FMT_YUV420P10BE: c->chrToYV12 = BE10ToUV_c; break; + case PIX_FMT_YUV420P10LE: c->chrToYV12 = LE10ToUV_c; break; case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: case PIX_FMT_YUV444P16BE: c->chrToYV12 = BEToUV_c; break; @@ -866,10 +870,10 @@ static void sws_init_swScale_c(SwsContext *c) c->lumToYV12 = NULL; c->alpToYV12 = NULL; switch (srcFormat) { - case PIX_FMT_YUV420P9BE: - case PIX_FMT_YUV420P9LE: c->lumToYV12 = yuv9ToY_c; break; - case PIX_FMT_YUV420P10BE: - case PIX_FMT_YUV420P10LE: c->lumToYV12 = yuv10ToY_c; break; + case PIX_FMT_YUV420P9BE: c->lumToYV12 = BE9ToY_c; break; + case PIX_FMT_YUV420P9LE: c->lumToYV12 = LE9ToY_c; break; + case PIX_FMT_YUV420P10BE: c->lumToYV12 = BE10ToY_c; break; + case PIX_FMT_YUV420P10LE: c->lumToYV12 = LE10ToY_c; break; case PIX_FMT_YUYV422 : case PIX_FMT_YUV420P16BE: case PIX_FMT_YUV422P16BE: diff --git a/libswscale/utils.c b/libswscale/utils.c index 4f9f269731..818d014159 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -143,9 +143,13 @@ int sws_isSupportedInput(enum PixelFormat pix_fmt) || (x)==PIX_FMT_GRAY8 \ || (x)==PIX_FMT_YUV410P \ || (x)==PIX_FMT_YUV440P \ + || (x)==PIX_FMT_YUV420P9LE \ + || (x)==PIX_FMT_YUV420P10LE \ || (x)==PIX_FMT_YUV420P16LE \ || (x)==PIX_FMT_YUV422P16LE \ || (x)==PIX_FMT_YUV444P16LE \ + || (x)==PIX_FMT_YUV420P9BE \ + || (x)==PIX_FMT_YUV420P10BE \ || (x)==PIX_FMT_YUV420P16BE \ || (x)==PIX_FMT_YUV422P16BE \ || (x)==PIX_FMT_YUV444P16BE \ diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index b1009cb4e9..d719721693 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2611,7 +2611,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, @@ -2688,7 +2688,7 @@ static int RENAME(swScale)(SwsContext *c, const uint8_t* src[], int srcStride[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat)) { + if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { yuv2yuvX16inC( vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrSrcPtr, vChrFilterSize, diff --git a/tests/fate/h264.mak b/tests/fate/h264.mak index 9cb669c1a0..5e6ff50e84 100644 --- a/tests/fate/h264.mak +++ b/tests/fate/h264.mak @@ -308,13 +308,13 @@ fate-h264-conformance-frext-hpcvfl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-co fate-h264-conformance-frext-hpcvflnl_bcrm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVFLNL_BRCM_A.264 -vsync 0 fate-h264-conformance-frext-hpcvmolq_brcm_b: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVMOLQ_BRCM_B.264 fate-h264-conformance-frext-hpcvnl_brcm_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/HPCVNL_BRCM_A.264 -fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264 -fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264 -fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264 -fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264 -fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264 -fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264 -fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264 +fate-h264-conformance-frext-pph10i1_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I1_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i2_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I2_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i3_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I3_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i4_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I4_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i5_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I5_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i6_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I6_Panasonic_A.264 -pix_fmt yuv420p10le +fate-h264-conformance-frext-pph10i7_panasonic_a: CMD = framecrc -i $(SAMPLES)/h264-conformance/FRext/PPH10I7_Panasonic_A.264 -pix_fmt yuv420p10le fate-h264-conformance-hcbp2_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCBP2_HHI_A.264 fate-h264-conformance-hcmp1_hhi_a: CMD = framecrc -vsync 0 -strict 1 -i $(SAMPLES)/h264-conformance/HCMP1_HHI_A.264 fate-h264-conformance-ls_sva_d: CMD = framecrc -i $(SAMPLES)/h264-conformance/LS_SVA_D.264 diff --git a/tests/ref/lavfi/pixdesc_le b/tests/ref/lavfi/pixdesc_le index 860f97d5b6..2078ae1abc 100644 --- a/tests/ref/lavfi/pixdesc_le +++ b/tests/ref/lavfi/pixdesc_le @@ -27,8 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291 yuv410p 2d9225153c83ee1132397d619d94d1b3 yuv411p 8b298af3e43348ca1b11eb8a3252ac6c yuv420p eba2f135a08829387e2f698ff72a2939 +yuv420p10be 7605e266c088d0fcf68c7b27c3ceff5f +yuv420p10le 4228ee628c6deec123a13b9784516cc7 yuv420p16be 16c009a235cd52b74791a895423152a3 yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc +yuv420p9be ce880fa07830e5297c22acf6e20555ce +yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_copy_le b/tests/ref/lavfi/pixfmts_copy_le index 860f97d5b6..2078ae1abc 100644 --- a/tests/ref/lavfi/pixfmts_copy_le +++ b/tests/ref/lavfi/pixfmts_copy_le @@ -27,8 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291 yuv410p 2d9225153c83ee1132397d619d94d1b3 yuv411p 8b298af3e43348ca1b11eb8a3252ac6c yuv420p eba2f135a08829387e2f698ff72a2939 +yuv420p10be 7605e266c088d0fcf68c7b27c3ceff5f +yuv420p10le 4228ee628c6deec123a13b9784516cc7 yuv420p16be 16c009a235cd52b74791a895423152a3 yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc +yuv420p9be ce880fa07830e5297c22acf6e20555ce +yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_null_le b/tests/ref/lavfi/pixfmts_null_le index 860f97d5b6..2078ae1abc 100644 --- a/tests/ref/lavfi/pixfmts_null_le +++ b/tests/ref/lavfi/pixfmts_null_le @@ -27,8 +27,12 @@ uyvy422 adcf64516a19fce44df77082bdb16291 yuv410p 2d9225153c83ee1132397d619d94d1b3 yuv411p 8b298af3e43348ca1b11eb8a3252ac6c yuv420p eba2f135a08829387e2f698ff72a2939 +yuv420p10be 7605e266c088d0fcf68c7b27c3ceff5f +yuv420p10le 4228ee628c6deec123a13b9784516cc7 yuv420p16be 16c009a235cd52b74791a895423152a3 yuv420p16le 2d59c4f1d0314a5a957a7cfc4b6fabcc +yuv420p9be ce880fa07830e5297c22acf6e20555ce +yuv420p9le 16543fda8f87d94a6cf857d2e8d4461a yuv422p c9bba4529821d796a6ab09f6a5fd355a yuv422p16be 5499502e1c29534a158a1fe60e889f60 yuv422p16le e3d61fde6978591596bc36b914386623 diff --git a/tests/ref/lavfi/pixfmts_scale_le b/tests/ref/lavfi/pixfmts_scale_le index 49f68a82e4..cbccb41cbd 100644 --- a/tests/ref/lavfi/pixfmts_scale_le +++ b/tests/ref/lavfi/pixfmts_scale_le @@ -27,8 +27,12 @@ uyvy422 314bd486277111a95d9369b944fa0400 yuv410p 7df8f6d69b56a8dcb6c7ee908e5018b5 yuv411p 1143e7c5cc28fe0922b051b17733bc4c yuv420p fdad2d8df8985e3d17e73c71f713cb14 +yuv420p10be 5051128ca208d89595f7672b1707340b +yuv420p10le 77895bf65e70ad2ca021702fff55c8fc yuv420p16be 29a0265764530070f5cd3251cc01f66a yuv420p16le 6f3a265b084a78baec229238d9f7945f +yuv420p9be 02de6b37dc8a631ce2367b535670c40c +yuv420p9le cddfbaf8e2a61aa5ea09fb396bcbc872 yuv422p 918e37701ee7377d16a8a6c119c56a40 yuv422p16be ef3e865fc1d0c68977c735323c50af6e yuv422p16le 428a9b96214c09cb5a983ce36d6961ff diff --git a/tests/ref/lavfi/pixfmts_vflip_le b/tests/ref/lavfi/pixfmts_vflip_le index 72fde29f56..698921a2a2 100644 --- a/tests/ref/lavfi/pixfmts_vflip_le +++ b/tests/ref/lavfi/pixfmts_vflip_le @@ -27,8 +27,12 @@ uyvy422 ffbd36720c77398d9a0d03ce2625928f yuv410p 7bfb39d7afb49d6a6173e6b23ae321eb yuv411p 4a90048cc3a65fac150e53289700efe1 yuv420p 2e6d6062e8cad37fb3ab2c433b55f382 +yuv420p10be df97d20b3b4a10c174d4360552c4160d +yuv420p10le 4b5249208602b941332945c926f80ae9 yuv420p16be 539076782902664a8acf381bf4f713e8 yuv420p16le 0f609e588e5a258644ef85170d70e030 +yuv420p9be be40ec975fb2873891643cbbbddbc3b0 +yuv420p9le 7e606310d3f5ff12badf911e8f333471 yuv422p d7f5cb44d9b0210d66d6a8762640ab34 yuv422p16be 9bd8f8c961822b586fa4cf992be54acc yuv422p16le 9c4a1239605c7952b736ac3130163f14 From f95257d27c91c7e1981e1f6a53c7e9217a3fae98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 11 May 2011 20:43:30 +0200 Subject: [PATCH 02/33] oggdec: simplify ogg_probe Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 07969c816f..bbd299d92d 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -642,12 +642,9 @@ static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp static int ogg_probe(AVProbeData *p) { - if (p->buf[0] == 'O' && p->buf[1] == 'g' && - p->buf[2] == 'g' && p->buf[3] == 'S' && - p->buf[4] == 0x0 && p->buf[5] <= 0x7 ) + if (!memcmp("OggS", p->buf, 5) && p->buf[5] <= 0x7) return AVPROBE_SCORE_MAX; - else - return 0; + return 0; } AVInputFormat ff_ogg_demuxer = { From b3bbc6fdc588ff03d9d1d2f17ef6608cf1cfff90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 11 May 2011 20:43:31 +0200 Subject: [PATCH 03/33] oggdec: use explicit AVInputFormat struct initializers Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index bbd299d92d..f9aeee7eb4 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -648,15 +648,15 @@ static int ogg_probe(AVProbeData *p) } AVInputFormat ff_ogg_demuxer = { - "ogg", - NULL_IF_CONFIG_SMALL("Ogg"), - sizeof (struct ogg), - ogg_probe, - ogg_read_header, - ogg_read_packet, - ogg_read_close, - ogg_read_seek, - ogg_read_timestamp, - .extensions = "ogg", - .flags = AVFMT_GENERIC_INDEX, + .name = "ogg", + .long_name = NULL_IF_CONFIG_SMALL("Ogg"), + .priv_data_size = sizeof(struct ogg), + .read_probe = ogg_probe, + .read_header = ogg_read_header, + .read_packet = ogg_read_packet, + .read_close = ogg_read_close, + .read_seek = ogg_read_seek, + .read_timestamp = ogg_read_timestamp, + .extensions = "ogg", + .flags = AVFMT_GENERIC_INDEX, }; From 45faf7fcd335b91e41b0e3ba4e397a9640d8c694 Mon Sep 17 00:00:00 2001 From: Thierry Foucu Date: Wed, 11 May 2011 21:27:04 -0700 Subject: [PATCH 04/33] nsv: Fix misdetection of MP3 files as NSV. If an MP3 file contains the string NSVs, the NSV probe will confuse it for an NSV file. Check for 0xBEEF after a Video/Audio chunk to achieve more accuracy. Signed-off-by: Diego Biurrun --- libavformat/nsvdec.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c index b70d3b9943..8f55bbc841 100644 --- a/libavformat/nsvdec.c +++ b/libavformat/nsvdec.c @@ -737,6 +737,9 @@ static int nsv_read_close(AVFormatContext *s) static int nsv_probe(AVProbeData *p) { int i; + int score; + int vsize, asize, auxcount; + score = 0; av_dlog(NULL, "nsv_probe(), buf_size %d\n", p->buf_size); /* check file header */ /* streamed files might not have any header */ @@ -749,14 +752,25 @@ static int nsv_probe(AVProbeData *p) /* sometimes even the first header is at 9KB or something :^) */ for (i = 1; i < p->buf_size - 3; i++) { if (p->buf[i+0] == 'N' && p->buf[i+1] == 'S' && - p->buf[i+2] == 'V' && p->buf[i+3] == 's') - return AVPROBE_SCORE_MAX-20; + p->buf[i+2] == 'V' && p->buf[i+3] == 's') { + score = AVPROBE_SCORE_MAX/5; + /* Get the chunk size and check if at the end we are getting 0xBEEF */ + auxcount = p->buf[i+19]; + vsize = p->buf[i+20] | p->buf[i+21] << 8; + asize = p->buf[i+22] | p->buf[i+23] << 8; + vsize = (vsize << 4) | (auxcount >> 4); + if ((asize + vsize + i + 23) < p->buf_size - 2) { + if (p->buf[i+23+asize+vsize+1] == 0xEF && + p->buf[i+23+asize+vsize+2] == 0xBE) + return AVPROBE_SCORE_MAX-20; + } + } } /* so we'll have more luck on extension... */ if (av_match_ext(p->filename, "nsv")) return AVPROBE_SCORE_MAX/2; /* FIXME: add mime-type check */ - return 0; + return score; } AVInputFormat ff_nsv_demuxer = { From 046f081b46c8479820409cf8f530b988221bd15b Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 11 May 2011 17:52:51 +0200 Subject: [PATCH 05/33] configure: Do not unconditionally add -D_POSIX_C_SOURCE to CPPFLAGS. Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems since it causes certain system functions to be hidden on some (BSD) systems. The solution is to only add the flag on systems that really require it, i.e. glibc-based ones. This change makes BSD systems compile out-of-the-box without the need for adding specific flags manually. It also allows dropping a number of flags set manually on a file-per-file basis, but were only present to work around breakage introduced by the presence of _POSIX_C_SOURCE. Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems. We use XSI extensions in several places already, so it is preferable to define it globally instead of littering source files with individual #defines only needed for glibc. --- configure | 6 +++--- doc/general.texi | 8 -------- ffmpeg.c | 3 --- ffplay.c | 2 -- ffserver.c | 2 -- libavcodec/libxvidff.c | 3 --- libavdevice/bktr.c | 4 ---- libavdevice/x11grab.c | 2 -- libavformat/applehttp.c | 1 - libavformat/applehttpproto.c | 1 - libavformat/avio.c | 3 +-- libavformat/os_support.c | 1 - libavformat/rtpdec.c | 3 --- libavformat/udp.c | 2 +- libavutil/ppc/cpu.c | 2 -- libswscale/utils.c | 2 -- 16 files changed, 5 insertions(+), 40 deletions(-) diff --git a/configure b/configure index 955a568684..40f30ddbb6 100755 --- a/configure +++ b/configure @@ -1664,7 +1664,7 @@ LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"' CC_O='-o $@' -host_cflags='-D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 -O3 -g -Wall' +host_cflags='-D_ISOC99_SOURCE -O3 -g -Wall' host_libs='-lm' target_path='$(CURDIR)' @@ -2316,7 +2316,7 @@ if test "$?" != 0; then die "C compiler test failed." fi -add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112 +add_cppflags -D_ISOC99_SOURCE check_cflags -std=c99 check_cc -D_FILE_OFFSET_BITS=64 < @@ -2364,7 +2364,6 @@ case $target_os in disable symver oss_indev_extralibs="-lossaudio" oss_outdev_extralibs="-lossaudio" - add_cppflags -D_XOPEN_SOURCE=600 ;; openbsd) enable malloc_aligned @@ -2457,6 +2456,7 @@ case $target_os in enable dos_paths ;; linux) + add_cppflags -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 enable dv1394 ;; irix*) diff --git a/doc/general.texi b/doc/general.texi index 53482273f9..ce531ccdfb 100644 --- a/doc/general.texi +++ b/doc/general.texi @@ -785,14 +785,6 @@ to configure. BSD make will not build Libav, you need to install and use GNU Make (@file{gmake}). -@subsubsection FreeBSD, DragonFly BSD - -These systems will not compile out-of-the-box due to broken system headers. -Passing @code{--extra-cflags=-D__BSD_VISIBLE} to configure will work -around the problem. This may have unexpected sideeffects, so use it at -your own risk. If you care about FreeBSD, please make an attempt at -getting the system headers fixed. - @subsection (Open)Solaris GNU Make is required to build Libav, so you have to invoke (@file{gmake}), diff --git a/ffmpeg.c b/ffmpeg.c index 5ab3c7a508..b5ff4cfc30 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* needed for usleep() */ -#define _XOPEN_SOURCE 600 - #include "config.h" #include #include diff --git a/ffplay.c b/ffplay.c index 07727b667a..e820c603e3 100644 --- a/ffplay.c +++ b/ffplay.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define _XOPEN_SOURCE 600 - #include "config.h" #include #include diff --git a/ffserver.c b/ffserver.c index fe030b94c0..b4613af8fe 100644 --- a/ffserver.c +++ b/ffserver.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define _XOPEN_SOURCE 600 - #include "config.h" #if !HAVE_CLOSESOCKET #define closesocket close diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c index 96ce84872b..1e887a2a8c 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 #include #include "avcodec.h" diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c index ab70a1b2b7..dad5c834f1 100644 --- a/libavdevice/bktr.c +++ b/libavdevice/bktr.c @@ -24,10 +24,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define _BSD_SOURCE 1 -#define _NETBSD_SOURCE -#define _XOPEN_SOURCE 600 - #include "libavformat/avformat.h" #if HAVE_DEV_BKTR_IOCTL_METEOR_H && HAVE_DEV_BKTR_IOCTL_BT848_H # include diff --git a/libavdevice/x11grab.c b/libavdevice/x11grab.c index aaad7292c6..0e63d09fea 100644 --- a/libavdevice/x11grab.c +++ b/libavdevice/x11grab.c @@ -35,8 +35,6 @@ * and Edouard Gomez . */ -#define _XOPEN_SOURCE 600 - #include "config.h" #include "libavformat/avformat.h" #include diff --git a/libavformat/applehttp.c b/libavformat/applehttp.c index 822d80bb00..e3b1500044 100644 --- a/libavformat/applehttp.c +++ b/libavformat/applehttp.c @@ -25,7 +25,6 @@ * http://tools.ietf.org/html/draft-pantos-http-live-streaming */ -#define _XOPEN_SOURCE 600 #include "libavutil/avstring.h" #include "libavutil/intreadwrite.h" #include "libavutil/opt.h" diff --git a/libavformat/applehttpproto.c b/libavformat/applehttpproto.c index 37b289a1e0..85f3cfcef4 100644 --- a/libavformat/applehttpproto.c +++ b/libavformat/applehttpproto.c @@ -25,7 +25,6 @@ * http://tools.ietf.org/html/draft-pantos-http-live-streaming */ -#define _XOPEN_SOURCE 600 #include "libavutil/avstring.h" #include "avformat.h" #include "internal.h" diff --git a/libavformat/avio.c b/libavformat/avio.c index 0702aff007..8881f269f2 100644 --- a/libavformat/avio.c +++ b/libavformat/avio.c @@ -19,9 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* needed for usleep() */ -#define _XOPEN_SOURCE 600 #include + #include "libavutil/avstring.h" #include "libavutil/opt.h" #include "os_support.h" diff --git a/libavformat/os_support.c b/libavformat/os_support.c index 05577b7553..a0fcd6c9ba 100644 --- a/libavformat/os_support.c +++ b/libavformat/os_support.c @@ -22,7 +22,6 @@ /* needed by inet_aton() */ #define _SVID_SOURCE -#define _DARWIN_C_SOURCE #include "config.h" #include "avformat.h" diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index 43305a30c7..4623088c38 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -19,9 +19,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -/* needed for gethostname() */ -#define _XOPEN_SOURCE 600 - #include "libavcodec/get_bits.h" #include "avformat.h" #include "mpegts.h" diff --git a/libavformat/udp.c b/libavformat/udp.c index 62c1c7c107..d6522bf0be 100644 --- a/libavformat/udp.c +++ b/libavformat/udp.c @@ -25,7 +25,7 @@ */ #define _BSD_SOURCE /* Needed for using struct ip_mreq with recent glibc */ -#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */ + #include "avformat.h" #include "avio_internal.h" #include "libavutil/parseutils.h" diff --git a/libavutil/ppc/cpu.c b/libavutil/ppc/cpu.c index 6b122ed8c4..002571161a 100644 --- a/libavutil/ppc/cpu.c +++ b/libavutil/ppc/cpu.c @@ -17,10 +17,8 @@ */ #ifdef __APPLE__ -#undef _POSIX_C_SOURCE #include #elif defined(__OpenBSD__) -#undef _POSIX_C_SOURCE #include #include #include diff --git a/libswscale/utils.c b/libswscale/utils.c index 818d014159..e9319fa67b 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -18,8 +18,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#define _SVID_SOURCE //needed for MAP_ANONYMOUS -#define _DARWIN_C_SOURCE // needed for MAP_ANON #include #include #include From be898457081ac2610ad4184272e9254e8922ff59 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 29 Apr 2011 20:17:43 +0200 Subject: [PATCH 06/33] jfdct: Replace sized int_fast integer types with plain int/unsigned. int/unsigned is the natural memory access type for CPUs, using sized types for temporary variables, counters and similar just increases code size and can possibly cause a slowdown. --- libavcodec/jfdctfst.c | 18 +++++++++--------- libavcodec/jfdctint.c | 18 +++++++++--------- 2 files changed, 18 insertions(+), 18 deletions(-) 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; From 0a6b1a9f21d5970a0439e32303535ed85f07673e Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Fri, 29 Apr 2011 16:08:20 +0200 Subject: [PATCH 07/33] Replace int_fast integer types with their sized standard posix counterparts. The _fast integer types provide no realworld benefits, but may introduce portability issues and are just plain ugly. --- libavcodec/cavs.h | 11 +-- libavcodec/cavsdata.h | 8 +-- libavcodec/ffv1.c | 31 ++++++--- libavcodec/vorbis.c | 8 +-- libavcodec/vorbis.h | 10 +-- libavcodec/vorbisdec.c | 153 +++++++++++++++++++++-------------------- libavcodec/vorbisenc.c | 6 +- 7 files changed, 119 insertions(+), 108 deletions(-) diff --git a/libavcodec/cavs.h b/libavcodec/cavs.h index 32479ced58..eda76a8d8e 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 caed4e8962..210169f844 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 c4f37d72c1..53edbb3459 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 quant_table_count; @@ -279,7 +279,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]; @@ -287,7 +288,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]; @@ -506,7 +509,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; @@ -591,7 +597,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)); @@ -621,7 +627,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)); @@ -1305,7 +1311,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; @@ -1365,7 +1374,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; @@ -1374,7 +1383,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; ysample_buffer + x*2 *(w+6) + 3; sample[x][1] = s->sample_buffer + (x*2+1)*(w+6) + 3; @@ -1412,7 +1421,7 @@ static void decode_rgb_frame(FFV1Context *s, uint32_t *src, int w, int h, int st for(y=0; y 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; @@ -1143,10 +1146,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 class, cdim, cbits, csub, cval, offset, i, j; int book, adx, ady, dy, off, predicted, err; @@ -1248,7 +1251,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); } @@ -1266,7 +1269,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) @@ -1403,7 +1406,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) @@ -1451,12 +1454,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 74933af4d5..67d094b37d 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); } From 92fe25875616c902047732aaff1fa70390be57c9 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Fri, 25 Mar 2011 18:49:24 +0100 Subject: [PATCH 08/33] configure: sort filter deps entries Signed-off-by: Anton Khirnov --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 40f30ddbb6..d551379da4 100755 --- a/configure +++ b/configure @@ -1467,8 +1467,8 @@ drawtext_filter_deps="libfreetype" frei0r_filter_deps="frei0r dlopen strtok_r" frei0r_src_filter_deps="frei0r dlopen strtok_r" hqdn3d_filter_deps="gpl" -scale_filter_deps="swscale" ocv_filter_deps="libopencv" +scale_filter_deps="swscale" yadif_filter_deps="gpl" # libraries From c7d22c5d678e4a1977071296df7c151693358156 Mon Sep 17 00:00:00 2001 From: Peter Ross Date: Fri, 18 Mar 2011 22:28:52 +1100 Subject: [PATCH 09/33] patcheck: warn about assert usage Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- tools/patcheck | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/patcheck b/tools/patcheck index a8c0cc8cf7..19faf47b1d 100755 --- a/tools/patcheck +++ b/tools/patcheck @@ -84,6 +84,7 @@ hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' *\*( |\*)*(src|source|input|in[ hiegrep '(:\+|,|;)( *|static|\*)*'"$ERE_PRITYP"' *(src|source|input|in)([0-9A-Z_][0-9A-Za-z_]*){1,} *\[' 'missing const (test2)?' $* hiegrep ' *static *'"$ERE_FUNCS"'[^)]*\);' 'static prototype, maybe you should reorder your functions' $* hiegrep '@file: *[a-zA-Z0-9_]' 'doxy filetag with filename can in the future cause problems when forgotten during a rename' $* +hiegrep '\bassert' 'Please use av_assert0, av_assert1 or av_assert2' $* hiegrep2 '\.long_name *=' 'NULL_IF_CONFIG_SMAL' 'missing NULL_IF_CONFIG_SMAL' $* hiegrep2 '\.pix_fmts *= *\(' 'const' 'missing const for pix_fmts array' $* From 9c3f5ef663f2f36e951945969f99776bb12a3e7a Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Sun, 13 Mar 2011 21:22:59 +0100 Subject: [PATCH 10/33] ffprobe: tweak error message in open_input_file() Replace "codec (id=%d)" with "codec with id %d", slightly more readable. Signed-off-by: Anton Khirnov --- ffprobe.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ffprobe.c b/ffprobe.c index 6e26c115a7..b5d19f06d6 100644 --- a/ffprobe.c +++ b/ffprobe.c @@ -285,7 +285,7 @@ static int open_input_file(AVFormatContext **fmt_ctx_ptr, const char *filename) AVCodec *codec; if (!(codec = avcodec_find_decoder(stream->codec->codec_id))) { - fprintf(stderr, "Unsupported codec (id=%d) for input stream %d\n", + fprintf(stderr, "Unsupported codec with id %d for input stream %d\n", stream->codec->codec_id, stream->index); } else if (avcodec_open(stream->codec, codec) < 0) { fprintf(stderr, "Error while opening codec for input stream %d\n", From 6ae38aa3ce197905fb52a631c7dd1b2a5e535b3e Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Sun, 27 Feb 2011 16:19:50 -0800 Subject: [PATCH 11/33] mpegts: do not output known sized packet if an unbounded packet is already queued. Fix issue #2624. Signed-off-by: Anton Khirnov --- libavformat/mpegts.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c index cdefb84864..e20d6966e3 100644 --- a/libavformat/mpegts.c +++ b/libavformat/mpegts.c @@ -802,7 +802,7 @@ static int mpegts_push_data(MpegTSFilter *filter, * a couple of seconds to milliseconds for properly muxed files. * total_size is the number of bytes following pes_packet_length * in the pes header, i.e. not counting the first 6 bytes */ - if (pes->total_size < MAX_PES_PAYLOAD && + if (!ts->stop_parse && pes->total_size < MAX_PES_PAYLOAD && pes->pes_header_size + pes->data_index == pes->total_size + 6) { ts->stop_parse = 1; new_pes_packet(pes, ts->pkt); From 7fe3207e250991d16381096327c74125bafe3b70 Mon Sep 17 00:00:00 2001 From: Alex Converse Date: Sun, 27 Feb 2011 16:29:21 -0800 Subject: [PATCH 12/33] movenc: fix adpcm mono muxing. Signed-off-by: Anton Khirnov --- libavformat/movenc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 0327bdf797..1d3eb3fe5a 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -91,6 +91,7 @@ static int mov_write_stsz_tag(AVIOContext *pb, MOVTrack *track) } if (equalChunks) { int sSize = track->cluster[0].size/track->cluster[0].entries; + sSize = FFMAX(1, sSize); // adpcm mono case could make sSize == 0 avio_wb32(pb, sSize); // sample size avio_wb32(pb, entries); // sample count } From 304e983dc760176501b748ca99bcde23e7851013 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Wed, 23 Mar 2011 10:22:05 -0700 Subject: [PATCH 13/33] movenc: fix yuv range in avid atoms used by dnxhd. yuv range: full 1 / normal 2 Signed-off-by: Anton Khirnov --- libavformat/movenc.c | 2 +- tests/ref/vsynth1/dnxhd_1080i | 2 +- tests/ref/vsynth2/dnxhd_1080i | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 1d3eb3fe5a..bdd92f23b8 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -535,7 +535,7 @@ static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track) ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "ACLR"); ffio_wfourcc(pb, "0001"); - avio_wb32(pb, 1); /* yuv 1 / rgb 2 ? */ + avio_wb32(pb, 2); /* yuv range: full 1 / normal 2 */ avio_wb32(pb, 0); /* unknown */ avio_wb32(pb, 24); /* size */ diff --git a/tests/ref/vsynth1/dnxhd_1080i b/tests/ref/vsynth1/dnxhd_1080i index 654242c745..80484b50ae 100644 --- a/tests/ref/vsynth1/dnxhd_1080i +++ b/tests/ref/vsynth1/dnxhd_1080i @@ -1,4 +1,4 @@ -8a814d4056ca2810a8ed0bad3b70f358 *./tests/data/vsynth1/dnxhd-1080i.mov +34949ea38da2cf6a8406ad600ad95cfa *./tests/data/vsynth1/dnxhd-1080i.mov 3031875 ./tests/data/vsynth1/dnxhd-1080i.mov 0c651e840f860592f0d5b66030d9fa32 *./tests/data/dnxhd_1080i.vsynth1.out.yuv stddev: 6.29 PSNR: 32.15 MAXDIFF: 64 bytes: 760320/ 7603200 diff --git a/tests/ref/vsynth2/dnxhd_1080i b/tests/ref/vsynth2/dnxhd_1080i index 3dc0ef5e4a..ae988465f6 100644 --- a/tests/ref/vsynth2/dnxhd_1080i +++ b/tests/ref/vsynth2/dnxhd_1080i @@ -1,4 +1,4 @@ -c81c7cfb375f61b7ab9b60fa340fe52a *./tests/data/vsynth2/dnxhd-1080i.mov +995e433cd076e3c1534fa73181744a84 *./tests/data/vsynth2/dnxhd-1080i.mov 3031875 ./tests/data/vsynth2/dnxhd-1080i.mov 3c559af629ae0a8fb1a9a0e4b4da7733 *./tests/data/dnxhd_1080i.vsynth2.out.yuv stddev: 1.31 PSNR: 45.77 MAXDIFF: 23 bytes: 760320/ 7603200 From 14cf9e698dac48cacd5e7f378469afcbf96cf507 Mon Sep 17 00:00:00 2001 From: Baptiste Coudurier Date: Wed, 30 Mar 2011 08:47:30 -0700 Subject: [PATCH 14/33] dnxhdenc: add AVClass in private context. Fixes private options. Signed-off-by: Anton Khirnov --- libavcodec/dnxhdenc.c | 4 ++-- libavcodec/dnxhdenc.h | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index e00b6f67a3..78da1c15e2 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -433,7 +433,7 @@ static int dnxhd_calc_bits_thread(AVCodecContext *avctx, void *arg, int jobnr, i int n = dnxhd_switch_matrix(ctx, i); memcpy(block, src_block, 64*sizeof(*block)); - last_index = ctx->m.dct_quantize((MpegEncContext*)ctx, block, i, qscale, &overflow); + last_index = ctx->m.dct_quantize(&ctx->m, block, i, qscale, &overflow); ac_bits += dnxhd_calc_ac_bits(ctx, block, last_index); diff = block[0] - ctx->m.last_dc[n]; @@ -478,7 +478,7 @@ static int dnxhd_encode_thread(AVCodecContext *avctx, void *arg, int jobnr, int DCTELEM *block = ctx->blocks[i]; int last_index, overflow; int n = dnxhd_switch_matrix(ctx, i); - last_index = ctx->m.dct_quantize((MpegEncContext*)ctx, block, i, qscale, &overflow); + last_index = ctx->m.dct_quantize(&ctx->m, block, i, qscale, &overflow); //START_TIMER; dnxhd_encode_block(ctx, block, last_index, n); //STOP_TIMER("encode_block"); diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 83c0b1cacd..43f65e46dd 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -39,6 +39,7 @@ typedef struct { } RCEntry; typedef struct DNXHDEncContext { + AVClass *class; MpegEncContext m; ///< Used for quantization dsp functions AVFrame frame; From 2501d2f386be4ab252f547055610e746c826ca91 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Thu, 24 Mar 2011 01:54:15 +0100 Subject: [PATCH 15/33] matroskaenc: add missing new line in av_log() call Signed-off-by: Aurelien Jacobs Signed-off-by: Anton Khirnov --- libavformat/matroskaenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 781121a68f..4aa4cafd4c 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -616,7 +616,7 @@ static int mkv_write_tracks(AVFormatContext *s) put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE); break; default: - av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska."); + av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n"); break; } ret = mkv_write_codecprivate(s, pb, codec, native_id, qt_id); From 5780f41af5d9dcb4d32f06c026ecd146b143baf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 11 May 2011 20:43:27 +0200 Subject: [PATCH 16/33] oggdec: fix memleak with continuous streams. This avoids the creation of a new AVStream instead of replacing it when a stream reset occurs (track change with some webradios for example). Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index f9aeee7eb4..4731948afd 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -148,7 +148,7 @@ ogg_find_codec (uint8_t * buf, int size) } static int -ogg_new_stream (AVFormatContext * s, uint32_t serial) +ogg_new_stream (AVFormatContext *s, uint32_t serial, int new_avstream) { struct ogg *ogg = s->priv_data; @@ -165,11 +165,13 @@ ogg_new_stream (AVFormatContext * s, uint32_t serial) os->buf = av_malloc(os->bufsize); os->header = -1; - st = av_new_stream (s, idx); - if (!st) - return AVERROR(ENOMEM); + if (new_avstream) { + st = av_new_stream(s, idx); + if (!st) + return AVERROR(ENOMEM); - av_set_pts_info(st, 64, 1, 1000000); + av_set_pts_info(st, 64, 1, 1000000); + } return idx; } @@ -250,8 +252,10 @@ ogg_read_page (AVFormatContext * s, int *str) } ogg->curidx = -1; ogg->nstreams = 0; + idx = ogg_new_stream(s, serial, 0); + } else { + idx = ogg_new_stream(s, serial, 1); } - idx = ogg_new_stream (s, serial); if (idx < 0) return -1; } From e575685fad342b9a31e89c3897f7e105811f5194 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= Date: Wed, 11 May 2011 20:43:29 +0200 Subject: [PATCH 17/33] Cosmetics: fix prototypes in oggdec Signed-off-by: Diego Biurrun --- libavformat/oggdec.c | 51 ++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 33 deletions(-) diff --git a/libavformat/oggdec.c b/libavformat/oggdec.c index 4731948afd..67678059a1 100644 --- a/libavformat/oggdec.c +++ b/libavformat/oggdec.c @@ -55,8 +55,7 @@ static const struct ogg_codec * const ogg_codecs[] = { }; //FIXME We could avoid some structure duplication -static int -ogg_save (AVFormatContext * s) +static int ogg_save(AVFormatContext *s) { struct ogg *ogg = s->priv_data; struct ogg_state *ost = @@ -80,8 +79,7 @@ ogg_save (AVFormatContext * s) return 0; } -static int -ogg_restore (AVFormatContext * s, int discard) +static int ogg_restore(AVFormatContext *s, int discard) { struct ogg *ogg = s->priv_data; AVIOContext *bc = s->pb; @@ -109,8 +107,7 @@ ogg_restore (AVFormatContext * s, int discard) return 0; } -static int -ogg_reset (struct ogg * ogg) +static int ogg_reset(struct ogg *ogg) { int i; @@ -134,8 +131,7 @@ ogg_reset (struct ogg * ogg) return 0; } -static const struct ogg_codec * -ogg_find_codec (uint8_t * buf, int size) +static const struct ogg_codec *ogg_find_codec(uint8_t *buf, int size) { int i; @@ -147,8 +143,7 @@ ogg_find_codec (uint8_t * buf, int size) return NULL; } -static int -ogg_new_stream (AVFormatContext *s, uint32_t serial, int new_avstream) +static int ogg_new_stream(AVFormatContext *s, uint32_t serial, int new_avstream) { struct ogg *ogg = s->priv_data; @@ -176,8 +171,7 @@ ogg_new_stream (AVFormatContext *s, uint32_t serial, int new_avstream) return idx; } -static int -ogg_new_buf(struct ogg *ogg, int idx) +static int ogg_new_buf(struct ogg *ogg, int idx) { struct ogg_stream *os = ogg->streams + idx; uint8_t *nb = av_malloc(os->bufsize); @@ -193,8 +187,7 @@ ogg_new_buf(struct ogg *ogg, int idx) return 0; } -static int -ogg_read_page (AVFormatContext * s, int *str) +static int ogg_read_page(AVFormatContext *s, int *str) { AVIOContext *bc = s->pb; struct ogg *ogg = s->priv_data; @@ -311,8 +304,8 @@ ogg_read_page (AVFormatContext * s, int *str) return 0; } -static int -ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpos) +static int ogg_packet(AVFormatContext *s, int *str, int *dstart, int *dsize, + int64_t *fpos) { struct ogg *ogg = s->priv_data; int idx, i; @@ -439,8 +432,7 @@ ogg_packet (AVFormatContext * s, int *str, int *dstart, int *dsize, int64_t *fpo return 0; } -static int -ogg_get_headers (AVFormatContext * s) +static int ogg_get_headers(AVFormatContext *s) { struct ogg *ogg = s->priv_data; @@ -454,8 +446,7 @@ ogg_get_headers (AVFormatContext * s) return 0; } -static int -ogg_get_length (AVFormatContext * s) +static int ogg_get_length(AVFormatContext *s) { struct ogg *ogg = s->priv_data; int i; @@ -491,9 +482,7 @@ ogg_get_length (AVFormatContext * s) return 0; } - -static int -ogg_read_header (AVFormatContext * s, AVFormatParameters * ap) +static int ogg_read_header(AVFormatContext *s, AVFormatParameters *ap) { struct ogg *ogg = s->priv_data; int i; @@ -544,8 +533,7 @@ static int64_t ogg_calc_pts(AVFormatContext *s, int idx, int64_t *dts) return pts; } -static int -ogg_read_packet (AVFormatContext * s, AVPacket * pkt) +static int ogg_read_packet(AVFormatContext *s, AVPacket *pkt) { struct ogg *ogg; struct ogg_stream *os; @@ -585,9 +573,7 @@ retry: return psize; } - -static int -ogg_read_close (AVFormatContext * s) +static int ogg_read_close(AVFormatContext *s) { struct ogg *ogg = s->priv_data; int i; @@ -600,10 +586,8 @@ ogg_read_close (AVFormatContext * s) return 0; } - -static int64_t -ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg, - int64_t pos_limit) +static int64_t ogg_read_timestamp(AVFormatContext *s, int stream_index, + int64_t *pos_arg, int64_t pos_limit) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + stream_index; @@ -626,7 +610,8 @@ ogg_read_timestamp (AVFormatContext * s, int stream_index, int64_t * pos_arg, return pts; } -static int ogg_read_seek(AVFormatContext *s, int stream_index, int64_t timestamp, int flags) +static int ogg_read_seek(AVFormatContext *s, int stream_index, + int64_t timestamp, int flags) { struct ogg *ogg = s->priv_data; struct ogg_stream *os = ogg->streams + stream_index; From ced9556b6189de67dd740f5231c6f1807f3e3704 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5ns=20Rullg=C3=A5rd?= Date: Thu, 12 May 2011 13:21:49 +0100 Subject: [PATCH 18/33] configure: Enable libpostproc automatically if GPL code is enabled. Enabling libpostproc automatically should give it more compile coverage and save the FATE box maintainers some configuration hassles. --- configure | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/configure b/configure index d551379da4..126a6b551c 100755 --- a/configure +++ b/configure @@ -88,7 +88,7 @@ Configuration options: --disable-avcodec disable libavcodec build --disable-avformat disable libavformat build --disable-swscale disable libswscale build - --enable-postproc enable GPLed postprocessing support [no] + --disable-postproc disable libpostproc build --disable-avfilter disable video filter support [no] --disable-pthreads disable pthreads [auto] --enable-w32threads use Win32 threads [no] @@ -1474,6 +1474,7 @@ yadif_filter_deps="gpl" # libraries avdevice_deps="avcodec avformat" avformat_deps="avcodec" +postproc_deps="gpl" # programs ffmpeg_deps="avcodec avformat swscale" @@ -1643,6 +1644,7 @@ enable ffprobe enable ffserver enable network enable optimizations +enable postproc enable protocols enable static enable swscale @@ -2531,7 +2533,6 @@ die_license_disabled() { die_license_disabled gpl libx264 die_license_disabled gpl libxavs die_license_disabled gpl libxvid -die_license_disabled gpl postproc die_license_disabled gpl x11grab die_license_disabled nonfree libfaac From 5f0bb0baefd506d684adfa1ad4259c65973b455e Mon Sep 17 00:00:00 2001 From: Yusuke Nakamura Date: Thu, 12 May 2011 05:28:27 +0900 Subject: [PATCH 19/33] mov: Support edit list atom version 1. Signed-off-by: Diego Biurrun --- libavformat/isom.h | 2 +- libavformat/mov.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/libavformat/isom.h b/libavformat/isom.h index 48e0bcf9e2..ef3fe1484f 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -109,7 +109,7 @@ typedef struct MOVStreamContext { unsigned int keyframe_count; int *keyframes; int time_scale; - int time_offset; ///< time offset of the first edit list entry + int64_t time_offset; ///< time offset of the first edit list entry int current_sample; unsigned int bytes_per_frame; unsigned int samples_per_frame; diff --git a/libavformat/mov.c b/libavformat/mov.c index 90f583f81b..cede1f751a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -2163,13 +2163,13 @@ free_and_return: static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) { MOVStreamContext *sc; - int i, edit_count; + int i, edit_count, version; if (c->fc->nb_streams < 1) return 0; sc = c->fc->streams[c->fc->nb_streams-1]->priv_data; - avio_r8(pb); /* version */ + version = avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ edit_count = avio_rb32(pb); /* entries */ @@ -2177,9 +2177,15 @@ static int mov_read_elst(MOVContext *c, AVIOContext *pb, MOVAtom atom) return -1; for(i=0; i= -1) { sc->time_offset = time != -1 ? time : -duration; From 8102d886be012dc7a519da23b3278d36ae860f6d Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 9 May 2011 21:05:42 +0200 Subject: [PATCH 20/33] tiff: Prefer enum TiffCompr over int for TiffContext.compr. This is safer and helps debugging. Signed-off-by: Diego Biurrun --- libavcodec/tiff.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 1ec78a7125..0cd1cddd62 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -42,7 +42,7 @@ typedef struct TiffContext { int width, height; unsigned int bpp; int le; - int compr; + enum TiffCompr compr; int invert; int fax_opts; int predictor; From bbc572a2c4d6d71b1c43e7853dd8caba3234dff6 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 9 May 2011 12:51:24 +0200 Subject: [PATCH 21/33] tiff: add support for SamplesPerPixel tag in tiff_decode_tag() Format detection and internal frame initialization is moved to a separate init_image() function, which is called when all the tags have been read, and so both BitsPerSample and SamplesPerPixel information has been collected. This fixes decoding of the file 11.tiff from roundup issue #1925. Based on a patch by Kostya Shishkov . Signed-off-by: Diego Biurrun --- libavcodec/tiff.c | 122 ++++++++++++++++++++++++---------------------- 1 file changed, 65 insertions(+), 57 deletions(-) diff --git a/libavcodec/tiff.c b/libavcodec/tiff.c index 0cd1cddd62..ffa5c6837a 100644 --- a/libavcodec/tiff.c +++ b/libavcodec/tiff.c @@ -40,7 +40,7 @@ typedef struct TiffContext { AVFrame picture; int width, height; - unsigned int bpp; + unsigned int bpp, bppcount; int le; enum TiffCompr compr; int invert; @@ -216,6 +216,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) { @@ -269,6 +318,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; @@ -288,46 +338,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; @@ -469,7 +489,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; @@ -510,21 +530,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; From 5da116a3fde9013846bd7b385cdde5ce2951869c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 6 Apr 2011 21:17:32 +0200 Subject: [PATCH 22/33] ffmpeg: factorize quality calculation Calculate quality value once per stream in print_report(). Also fix segfault, as coded_frame can be NULL. Signed-off-by: Anton Khirnov --- ffmpeg.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ffmpeg.c b/ffmpeg.c index b5ff4cfc30..1c1be7c193 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -1322,26 +1322,25 @@ static void print_report(AVFormatContext **output_files, ti1 = 1e10; vid = 0; for(i=0;ist->codec; + if (!ost->st->stream_copy && enc->coded_frame) + q = enc->coded_frame->quality/(float)FF_QP2LAMBDA; if (vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { - snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", - !ost->st->stream_copy ? - enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1); + snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "q=%2.1f ", q); } if (!vid && enc->codec_type == AVMEDIA_TYPE_VIDEO) { float t = (av_gettime()-timer_start) / 1000000.0; frame_number = ost->frame_number; snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "frame=%5d fps=%3d q=%3.1f ", - frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, - !ost->st->stream_copy ? - enc->coded_frame->quality/(float)FF_QP2LAMBDA : -1); + frame_number, (t>1)?(int)(frame_number/t+0.5) : 0, q); if(is_last_report) snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "L"); if(qp_hist){ int j; - int qp= lrintf(enc->coded_frame->quality/(float)FF_QP2LAMBDA); + int qp = lrintf(q); if(qp>=0 && qp Date: Sun, 20 Feb 2011 01:18:49 +0100 Subject: [PATCH 23/33] lavf: fix av_find_best_stream when decoder_ret is given and using a related stream. Yet another fix for the code originally designed for use without related_stream. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 7959102e0a..830e5d03c2 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2484,7 +2484,7 @@ int av_find_best_stream(AVFormatContext *ic, if (st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED)) continue; if (decoder_ret) { - decoder = avcodec_find_decoder(ic->streams[i]->codec->codec_id); + decoder = avcodec_find_decoder(st->codec->codec_id); if (!decoder) { if (ret < 0) ret = AVERROR_DECODER_NOT_FOUND; From 2c7158169859eb2dd49a72337f9f3f28347da77a Mon Sep 17 00:00:00 2001 From: Marton Balint Date: Sun, 20 Feb 2011 01:18:30 +0100 Subject: [PATCH 24/33] lavf: fix av_find_best_stream when providing a wanted stream. In the main loop, stream_number is incremented after checking the stream type, so the search usually will not find the wanted stream. This patch eliminates the useless stream_number variable and introduces a new one, called real_stream_index to store the real stream index of the current stream, no matter if we are looping through all the streams or only the streams of a program. Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- libavformat/utils.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 830e5d03c2..2afac163c5 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2462,7 +2462,7 @@ int av_find_best_stream(AVFormatContext *ic, AVCodec **decoder_ret, int flags) { - int i, nb_streams = ic->nb_streams, stream_number = 0; + int i, nb_streams = ic->nb_streams; int ret = AVERROR_STREAM_NOT_FOUND, best_count = -1; unsigned *program = NULL; AVCodec *decoder = NULL, *best_decoder = NULL; @@ -2475,11 +2475,12 @@ int av_find_best_stream(AVFormatContext *ic, } } for (i = 0; i < nb_streams; i++) { - AVStream *st = ic->streams[program ? program[i] : i]; + int real_stream_index = program ? program[i] : i; + AVStream *st = ic->streams[real_stream_index]; AVCodecContext *avctx = st->codec; if (avctx->codec_type != type) continue; - if (wanted_stream_nb >= 0 && stream_number++ != wanted_stream_nb) + if (wanted_stream_nb >= 0 && real_stream_index != wanted_stream_nb) continue; if (st->disposition & (AV_DISPOSITION_HEARING_IMPAIRED|AV_DISPOSITION_VISUAL_IMPAIRED)) continue; @@ -2494,7 +2495,7 @@ int av_find_best_stream(AVFormatContext *ic, if (best_count >= st->codec_info_nb_frames) continue; best_count = st->codec_info_nb_frames; - ret = program ? program[i] : i; + ret = real_stream_index; best_decoder = decoder; if (program && i == nb_streams - 1 && ret < 0) { program = NULL; From 4ad0693edccdc01dc7415b9efdc96ea5ab0dbf34 Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Thu, 17 Mar 2011 12:52:40 +0100 Subject: [PATCH 25/33] lavf: fix function name in compute_pkt_fields2 av_dlog message Signed-off-by: Anton Khirnov --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 2afac163c5..67aa76ad75 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2851,7 +2851,7 @@ static int compute_pkt_fields2(AVFormatContext *s, AVStream *st, AVPacket *pkt){ int delay = FFMAX(st->codec->has_b_frames, !!st->codec->max_b_frames); int num, den, frame_size, i; - av_dlog(s, "av_write_frame: pts:%"PRId64" dts:%"PRId64" cur_dts:%"PRId64" b:%d size:%d st:%d\n", + av_dlog(s, "compute_pkt_fields2: pts:%"PRId64" dts:%"PRId64" cur_dts:%"PRId64" b:%d size:%d st:%d\n", pkt->pts, pkt->dts, st->cur_dts, delay, pkt->size, pkt->stream_index); /* if(pkt->pts == AV_NOPTS_VALUE && pkt->dts == AV_NOPTS_VALUE) From 9c569ef7129d2e2972a5caa9cc01899a502b4bbf Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Thu, 24 Mar 2011 00:28:19 +0100 Subject: [PATCH 26/33] matroskadec: check that pointers were initialized before accessing them Signed-off-by: Aurelien Jacobs Signed-off-by: Anton Khirnov --- libavformat/matroskadec.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c index 0fa94a16d5..9c11c71e1f 100644 --- a/libavformat/matroskadec.c +++ b/libavformat/matroskadec.c @@ -1084,19 +1084,21 @@ static void matroska_convert_tags(AVFormatContext *s) if (tags[i].target.attachuid) { MatroskaAttachement *attachment = matroska->attachments.elem; for (j=0; jattachments.nb_elem; j++) - if (attachment[j].uid == tags[i].target.attachuid) + if (attachment[j].uid == tags[i].target.attachuid + && attachment[j].stream) matroska_convert_tag(s, &tags[i].tag, &attachment[j].stream->metadata, NULL); } else if (tags[i].target.chapteruid) { MatroskaChapter *chapter = matroska->chapters.elem; for (j=0; jchapters.nb_elem; j++) - if (chapter[j].uid == tags[i].target.chapteruid) + if (chapter[j].uid == tags[i].target.chapteruid + && chapter[j].chapter) matroska_convert_tag(s, &tags[i].tag, &chapter[j].chapter->metadata, NULL); } else if (tags[i].target.trackuid) { MatroskaTrack *track = matroska->tracks.elem; for (j=0; jtracks.nb_elem; j++) - if (track[j].uid == tags[i].target.trackuid) + if (track[j].uid == tags[i].target.trackuid && track[j].stream) matroska_convert_tag(s, &tags[i].tag, &track[j].stream->metadata, NULL); } else { From 89d4c130574c6f2a617c5fde6f9b8a82da7a1e28 Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Thu, 24 Mar 2011 01:56:26 +0100 Subject: [PATCH 27/33] matroskaenc: make sure we don't produce invalid file with no codec ID Signed-off-by: Aurelien Jacobs Signed-off-by: Anton Khirnov --- libavformat/matroskaenc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 4aa4cafd4c..1bbabc9ff4 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -614,6 +614,10 @@ static int mkv_write_tracks(AVFormatContext *s) case AVMEDIA_TYPE_SUBTITLE: put_ebml_uint(pb, MATROSKA_ID_TRACKTYPE, MATROSKA_TRACK_TYPE_SUBTITLE); + if (!native_id) { + av_log(s, AV_LOG_ERROR, "Subtitle codec %d is not supported.\n", codec->codec_id); + return AVERROR(ENOSYS); + } break; default: av_log(s, AV_LOG_ERROR, "Only audio, video, and subtitles are supported for Matroska.\n"); From ee81e76db119c4ac4f52404d9d826969975aa77f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= Date: Mon, 21 Mar 2011 10:52:36 +0100 Subject: [PATCH 28/33] wmaenc: improve channel count and bitrate error handling in encode_init() Signed-off-by: Michael Niedermayer Signed-off-by: Anton Khirnov --- libavcodec/wmaenc.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/libavcodec/wmaenc.c b/libavcodec/wmaenc.c index d2e811fd49..3cdb4a0b9b 100644 --- a/libavcodec/wmaenc.c +++ b/libavcodec/wmaenc.c @@ -33,11 +33,17 @@ static int encode_init(AVCodecContext * avctx){ s->avctx = avctx; - if(avctx->channels > MAX_CHANNELS) - return -1; + if(avctx->channels > MAX_CHANNELS) { + av_log(avctx, AV_LOG_ERROR, "too many channels: got %i, need %i or fewer", + avctx->channels, MAX_CHANNELS); + return AVERROR(EINVAL); + } - if(avctx->bit_rate < 24*1000) - return -1; + if(avctx->bit_rate < 24*1000) { + av_log(avctx, AV_LOG_ERROR, "bitrate too low: got %i, need 24000 or higher\n", + avctx->bit_rate); + return AVERROR(EINVAL); + } /* extract flag infos */ flags1 = 0; From ea5fa19427fdaba332b908758f5779add7084bbe Mon Sep 17 00:00:00 2001 From: Aurelien Jacobs Date: Fri, 25 Mar 2011 01:02:53 +0100 Subject: [PATCH 29/33] srtdec: make sure we don't write past the end of buffer Signed-off-by: Aurelien Jacobs Signed-off-by: Anton Khirnov --- libavcodec/srtdec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/srtdec.c b/libavcodec/srtdec.c index da625aacbf..677c5501f8 100644 --- a/libavcodec/srtdec.c +++ b/libavcodec/srtdec.c @@ -94,7 +94,7 @@ static const char *srt_to_ass(AVCodecContext *avctx, char *out, char *out_end, break; case '<': tag_close = in[1] == '/'; - if (sscanf(in+tag_close+1, "%128[^>]>%n%c", buffer, &len,&c) >= 2) { + if (sscanf(in+tag_close+1, "%127[^>]>%n%c", buffer, &len,&c) >= 2) { if ((param = strchr(buffer, ' '))) *param++ = 0; if ((!tag_close && sptr < FF_ARRAY_ELEMS(stack)) || From c4fb3b0327dc911a7b46b8b8193e97b1fb4afe65 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Wed, 23 Feb 2011 23:38:52 +0100 Subject: [PATCH 30/33] mpegvideo: make FF_DEBUG_DCT_COEFF output coeffs via av_log() instead of just via AVFrame. This allows the values to be used without changing C code and is closer to how the other DEBUG flags work. Signed-off-by: Anton Khirnov --- libavcodec/mpegvideo.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 2c0525e2ad..09e813476a 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -1869,9 +1869,14 @@ void MPV_decode_mb_internal(MpegEncContext *s, DCTELEM block[12][64], /* save DCT coefficients */ int i,j; DCTELEM *dct = &s->current_picture.dct_coeff[mb_xy*64*6]; - for(i=0; i<6; i++) - for(j=0; j<64; j++) + av_log(s->avctx, AV_LOG_DEBUG, "DCT coeffs of MB at %dx%d:\n", s->mb_x, s->mb_y); + for(i=0; i<6; i++){ + for(j=0; j<64; j++){ *dct++ = block[i][s->dsp.idct_permutation[j]]; + av_log(s->avctx, AV_LOG_DEBUG, "%5d", dct[-1]); + } + av_log(s->avctx, AV_LOG_DEBUG, "\n"); + } } s->current_picture.qscale_table[mb_xy]= s->qscale; From 257de756fb3da2576c8641e0a31f1785e2439f9d Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 30 Apr 2011 15:52:55 -0400 Subject: [PATCH 31/33] ac3enc: clean up count_frame_bits() and count_frame_bits_fixed() --- libavcodec/ac3enc.c | 66 +++++++++++++++++++++++++++++++-------------- 1 file changed, 46 insertions(+), 20 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 860208d493..753559fbb3 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -818,35 +818,57 @@ 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++; + + /* stereo rematrixing */ + if (s->channel_mode == AC3_CHMODE_STEREO) + 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; } @@ -896,6 +918,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) { @@ -905,6 +928,7 @@ 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 && @@ -912,11 +936,13 @@ static void count_frame_bits(AC3EncodeContext *s) 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; } From 4d7a4215748e8dc3740dfe6be4070ce055df6023 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Sat, 30 Apr 2011 15:55:18 -0400 Subject: [PATCH 32/33] ac3enc: put the counting of stereo rematrixing bits in the same place to make the code easier to understand. --- libavcodec/ac3enc.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 753559fbb3..95bdc58f16 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -838,10 +838,6 @@ static void count_frame_bits_fixed(AC3EncodeContext *s) if (!blk) frame_bits++; - /* stereo rematrixing */ - if (s->channel_mode == AC3_CHMODE_STEREO) - frame_bits++; - /* exponent strategy */ frame_bits += 2 * s->fbw_channels; if (s->lfe_on) @@ -931,9 +927,10 @@ static void count_frame_bits(AC3EncodeContext *s) /* 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 */ From 552a99957f7c6f6ed13795caee7ab7b9deb5d76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Thu, 12 May 2011 22:47:53 +0300 Subject: [PATCH 33/33] rtpdec_qdm2: Don't try to parse data packet if no configuration is received MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The later parsing of payload data depends on the configuration being present. If it hasn't been configured properly yet, parsing a data packet may lead to a crash. Signed-off-by: Martin Storsjö --- libavformat/rtpdec_qdm2.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/rtpdec_qdm2.c b/libavformat/rtpdec_qdm2.c index 7f5f0771bc..66dd874003 100644 --- a/libavformat/rtpdec_qdm2.c +++ b/libavformat/rtpdec_qdm2.c @@ -266,6 +266,8 @@ static int qdm2_parse_packet(AVFormatContext *s, PayloadContext *qdm, * to the decoder that it is OK to initialize. */ st->codec->codec_id = CODEC_ID_QDM2; } + if (st->codec->codec_id == CODEC_ID_NONE) + return AVERROR(EAGAIN); /* subpackets */ while (end - p >= 4) {