mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-06-29 04:17:06 +08:00
Merge commit 'ceb754d041f5f6327fd9195a5f43575af9516daa'
* commit 'ceb754d041f5f6327fd9195a5f43575af9516daa': lzo: Use AV_COPY*U macros where appropriate prepare 9_beta2 release dsputil: Replace AV_WNxx(AV_RNxx()) combinations by AV_COPYxxU intreadwrite: Add AV_COPYxxU macros for copying to/from unaligned addresses dxtory: Replace AV_WN16A(AV_RN16A()) combination by AV_COPY16 mp3: properly forward mp_decode_frame errors Conflicts: RELEASE libavcodec/mpegaudiodec.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
@ -674,7 +674,7 @@ static inline void copy_block2(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN16(dst , AV_RN16(src ));
|
AV_COPY16U(dst, src);
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
}
|
}
|
||||||
@ -685,7 +685,7 @@ static inline void copy_block4(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN32(dst , AV_RN32(src ));
|
AV_COPY32U(dst, src);
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
}
|
}
|
||||||
@ -696,8 +696,7 @@ static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN32(dst , AV_RN32(src ));
|
AV_COPY64U(dst, src);
|
||||||
AV_WN32(dst+4 , AV_RN32(src+4 ));
|
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
}
|
}
|
||||||
@ -708,8 +707,7 @@ static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN32(dst , AV_RN32(src ));
|
AV_COPY64U(dst, src);
|
||||||
AV_WN32(dst+4 , AV_RN32(src+4 ));
|
|
||||||
dst[8]= src[8];
|
dst[8]= src[8];
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
@ -721,10 +719,7 @@ static inline void copy_block16(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN32(dst , AV_RN32(src ));
|
AV_COPY128U(dst, src);
|
||||||
AV_WN32(dst+4 , AV_RN32(src+4 ));
|
|
||||||
AV_WN32(dst+8 , AV_RN32(src+8 ));
|
|
||||||
AV_WN32(dst+12, AV_RN32(src+12));
|
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
}
|
}
|
||||||
@ -735,10 +730,7 @@ static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride,
|
|||||||
int i;
|
int i;
|
||||||
for(i=0; i<h; i++)
|
for(i=0; i<h; i++)
|
||||||
{
|
{
|
||||||
AV_WN32(dst , AV_RN32(src ));
|
AV_COPY128U(dst, src);
|
||||||
AV_WN32(dst+4 , AV_RN32(src+4 ));
|
|
||||||
AV_WN32(dst+8 , AV_RN32(src+8 ));
|
|
||||||
AV_WN32(dst+12, AV_RN32(src+12));
|
|
||||||
dst[16]= src[16];
|
dst[16]= src[16];
|
||||||
dst+=dstStride;
|
dst+=dstStride;
|
||||||
src+=srcStride;
|
src+=srcStride;
|
||||||
|
@ -70,8 +70,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
|
|||||||
V = pic->data[2];
|
V = pic->data[2];
|
||||||
for (h = 0; h < avctx->height; h += 2) {
|
for (h = 0; h < avctx->height; h += 2) {
|
||||||
for (w = 0; w < avctx->width; w += 2) {
|
for (w = 0; w < avctx->width; w += 2) {
|
||||||
AV_WN16A(Y1 + w, AV_RN16A(src));
|
AV_COPY16(Y1 + w, src);
|
||||||
AV_WN16A(Y2 + w, AV_RN16A(src + 2));
|
AV_COPY16(Y2 + w, src + 2);
|
||||||
U[w >> 1] = src[4] + 0x80;
|
U[w >> 1] = src[4] + 0x80;
|
||||||
V[w >> 1] = src[5] + 0x80;
|
V[w >> 1] = src[5] + 0x80;
|
||||||
src += 6;
|
src += 6;
|
||||||
|
@ -1654,7 +1654,7 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
|||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
MPADecodeContext *s = avctx->priv_data;
|
MPADecodeContext *s = avctx->priv_data;
|
||||||
uint32_t header;
|
uint32_t header;
|
||||||
int out_size;
|
int ret;
|
||||||
|
|
||||||
while(buf_size && !*buf){
|
while(buf_size && !*buf){
|
||||||
buf++;
|
buf++;
|
||||||
@ -1693,21 +1693,22 @@ static int decode_frame(AVCodecContext * avctx, void *data, int *got_frame_ptr,
|
|||||||
buf_size= s->frame_size;
|
buf_size= s->frame_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_size = mp_decode_frame(s, NULL, buf, buf_size);
|
ret = mp_decode_frame(s, NULL, buf, buf_size);
|
||||||
if (out_size >= 0) {
|
if (ret >= 0) {
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = s->frame;
|
*(AVFrame *)data = s->frame;
|
||||||
avctx->sample_rate = s->sample_rate;
|
avctx->sample_rate = s->sample_rate;
|
||||||
//FIXME maybe move the other codec info stuff from above here too
|
//FIXME maybe move the other codec info stuff from above here too
|
||||||
} else {
|
} else {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
|
av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
|
||||||
/* Only return an error if the bad frame makes up the whole packet.
|
/* Only return an error if the bad frame makes up the whole packet or
|
||||||
If there is more data in the packet, just consume the bad frame
|
* the error is related to buffer management.
|
||||||
instead of returning an error, which would discard the whole
|
* If there is more data in the packet, just consume the bad frame
|
||||||
packet. */
|
* instead of returning an error, which would discard the whole
|
||||||
|
* packet. */
|
||||||
*got_frame_ptr = 0;
|
*got_frame_ptr = 0;
|
||||||
if (buf_size == avpkt->size)
|
if (buf_size == avpkt->size || ret != AVERROR_INVALIDDATA)
|
||||||
return out_size;
|
return ret;
|
||||||
}
|
}
|
||||||
s->frame_size = 0;
|
s->frame_size = 0;
|
||||||
return buf_size;
|
return buf_size;
|
||||||
@ -1732,7 +1733,7 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data,
|
|||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
MPADecodeContext *s = avctx->priv_data;
|
MPADecodeContext *s = avctx->priv_data;
|
||||||
uint32_t header;
|
uint32_t header;
|
||||||
int len;
|
int len, ret;
|
||||||
int av_unused out_size;
|
int av_unused out_size;
|
||||||
|
|
||||||
len = buf_size;
|
len = buf_size;
|
||||||
@ -1764,10 +1765,10 @@ static int decode_frame_adu(AVCodecContext *avctx, void *data,
|
|||||||
|
|
||||||
s->frame_size = len;
|
s->frame_size = len;
|
||||||
|
|
||||||
out_size = mp_decode_frame(s, NULL, buf, buf_size);
|
ret = mp_decode_frame(s, NULL, buf, buf_size);
|
||||||
if (out_size < 0) {
|
if (ret < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
|
av_log(avctx, AV_LOG_ERROR, "Error while decoding MPEG audio frame.\n");
|
||||||
return AVERROR_INVALIDDATA;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
@ -1972,7 +1973,10 @@ static int decode_frame_mp3on4(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
ch += m->nb_channels;
|
ch += m->nb_channels;
|
||||||
|
|
||||||
out_size += mp_decode_frame(m, outptr, buf, fsize);
|
if ((ret = mp_decode_frame(m, outptr, buf, fsize)) < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
out_size += ret;
|
||||||
buf += fsize;
|
buf += fsize;
|
||||||
len -= fsize;
|
len -= fsize;
|
||||||
|
|
||||||
|
@ -468,6 +468,33 @@ union unaligned_16 { uint16_t l; } __attribute__((packed)) av_alias;
|
|||||||
# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
# define AV_WN64A(p, v) AV_WNA(64, p, v)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The AV_COPYxxU macros are suitable for copying data to/from unaligned
|
||||||
|
* memory locations.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define AV_COPYU(n, d, s) AV_WN##n(d, AV_RN##n(s));
|
||||||
|
|
||||||
|
#ifndef AV_COPY16U
|
||||||
|
# define AV_COPY16U(d, s) AV_COPYU(16, d, s)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AV_COPY32U
|
||||||
|
# define AV_COPY32U(d, s) AV_COPYU(32, d, s)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AV_COPY64U
|
||||||
|
# define AV_COPY64U(d, s) AV_COPYU(64, d, s)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef AV_COPY128U
|
||||||
|
# define AV_COPY128U(d, s) \
|
||||||
|
do { \
|
||||||
|
AV_COPY64U(d, s); \
|
||||||
|
AV_COPY64U((char *)(d) + 8, (const char *)(s) + 8); \
|
||||||
|
} while(0)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
/* Parameters for AV_COPY*, AV_SWAP*, AV_ZERO* must be
|
||||||
* naturally aligned. They may be implemented using MMX,
|
* naturally aligned. They may be implemented using MMX,
|
||||||
* so emms_c() must be called before using any float code
|
* so emms_c() must be called before using any float code
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include "avutil.h"
|
#include "avutil.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
#include "intreadwrite.h"
|
||||||
#include "lzo.h"
|
#include "lzo.h"
|
||||||
|
|
||||||
/// Define if we may write up to 12 bytes beyond the output buffer.
|
/// Define if we may write up to 12 bytes beyond the output buffer.
|
||||||
@ -71,19 +72,6 @@ static inline int get_len(LZOContext *c, int x, int mask)
|
|||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define UNALIGNED_LOADSTORE
|
|
||||||
#define BUILTIN_MEMCPY
|
|
||||||
#ifdef UNALIGNED_LOADSTORE
|
|
||||||
#define COPY2(d, s) *(uint16_t *)(d) = *(uint16_t *)(s);
|
|
||||||
#define COPY4(d, s) *(uint32_t *)(d) = *(uint32_t *)(s);
|
|
||||||
#elif defined(BUILTIN_MEMCPY)
|
|
||||||
#define COPY2(d, s) memcpy(d, s, 2);
|
|
||||||
#define COPY4(d, s) memcpy(d, s, 4);
|
|
||||||
#else
|
|
||||||
#define COPY2(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1];
|
|
||||||
#define COPY4(d, s) (d)[0] = (s)[0]; (d)[1] = (s)[1]; (d)[2] = (s)[2]; (d)[3] = (s)[3];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Copies bytes from input to output buffer with checking.
|
* @brief Copies bytes from input to output buffer with checking.
|
||||||
* @param cnt number of bytes to copy, must be >= 0
|
* @param cnt number of bytes to copy, must be >= 0
|
||||||
@ -101,7 +89,7 @@ static inline void copy(LZOContext *c, int cnt)
|
|||||||
c->error |= AV_LZO_OUTPUT_FULL;
|
c->error |= AV_LZO_OUTPUT_FULL;
|
||||||
}
|
}
|
||||||
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
|
#if defined(INBUF_PADDED) && defined(OUTBUF_PADDED)
|
||||||
COPY4(dst, src);
|
AV_COPY32U(dst, src);
|
||||||
src += 4;
|
src += 4;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
cnt -= 4;
|
cnt -= 4;
|
||||||
@ -145,16 +133,16 @@ static inline void memcpy_backptr(uint8_t *dst, int back, int cnt)
|
|||||||
memset(dst, *src, cnt);
|
memset(dst, *src, cnt);
|
||||||
} else {
|
} else {
|
||||||
#ifdef OUTBUF_PADDED
|
#ifdef OUTBUF_PADDED
|
||||||
COPY2(dst, src);
|
AV_COPY16U(dst, src);
|
||||||
COPY2(dst + 2, src + 2);
|
AV_COPY16U(dst + 2, src + 2);
|
||||||
src += 4;
|
src += 4;
|
||||||
dst += 4;
|
dst += 4;
|
||||||
cnt -= 4;
|
cnt -= 4;
|
||||||
if (cnt > 0) {
|
if (cnt > 0) {
|
||||||
COPY2(dst, src);
|
AV_COPY16U(dst, src);
|
||||||
COPY2(dst + 2, src + 2);
|
AV_COPY16U(dst + 2, src + 2);
|
||||||
COPY2(dst + 4, src + 4);
|
AV_COPY16U(dst + 4, src + 4);
|
||||||
COPY2(dst + 6, src + 6);
|
AV_COPY16U(dst + 6, src + 6);
|
||||||
src += 8;
|
src += 8;
|
||||||
dst += 8;
|
dst += 8;
|
||||||
cnt -= 8;
|
cnt -= 8;
|
||||||
|
Reference in New Issue
Block a user