On Wed, Mar 21, 2012 at 02:00:41PM -0400, Justin Ruggles wrote:
> ---
> libavcodec/adxenc.c | 36 ++++++++++++++++++++----------------
> 1 files changed, 20 insertions(+), 16 deletions(-)
>
> diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
> index 591c075..45db48a 100644
> --- a/libavcodec/adxenc.c
> +++ b/libavcodec/adxenc.c
> @@ -22,6 +22,7 @@
> #include "avcodec.h"
> #include "adx.h"
> #include "bytestream.h"
> +#include "internal.h"
> #include "put_bits.h"
>
> /**
> @@ -87,9 +88,6 @@ static int adx_encode_header(AVCodecContext *avctx, uint8_t
> *buf, int bufsize)
> {
> ADXContext *c = avctx->priv_data;
>
> - if (bufsize < HEADER_SIZE)
> - return AVERROR(EINVAL);
> -
> bytestream_put_be16(&buf, 0x8000); /* header signature */
> bytestream_put_be16(&buf, HEADER_SIZE - 4); /* copyright offset */
> bytestream_put_byte(&buf, 3); /* encoding */
> @@ -119,8 +117,10 @@ static av_cold int adx_encode_init(AVCodecContext *avctx)
> }
> avctx->frame_size = BLOCK_SAMPLES;
>
> +#if FF_API_OLD_ENCODE_AUDIO
> avcodec_get_frame_defaults(&c->frame);
> avctx->coded_frame = &c->frame;
> +#endif
>
> /* the cutoff can be adjusted, but this seems to work pretty well */
> c->cutoff = 500;
> @@ -129,34 +129,38 @@ static av_cold int adx_encode_init(AVCodecContext
> *avctx)
> return 0;
> }
>
> -static int adx_encode_frame(AVCodecContext *avctx, uint8_t *frame,
> - int buf_size, void *data)
> +static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
> + const AVFrame *frame, int *got_packet_ptr)
> {
> ADXContext *c = avctx->priv_data;
> - const int16_t *samples = data;
> - uint8_t *dst = frame;
> - int ch;
> + const int16_t *samples = (const int16_t *)frame->data[0];
> + uint8_t *dst;
> + int ch, out_size, ret;
> +
> + out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed *
> HEADER_SIZE;
> + if ((ret = ff_alloc_packet(avpkt, out_size))) {
> + av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n");
> + return ret;
> + }
> + dst = avpkt->data;
nit: I'd add == 0, otherwise condition looks too LISPy
in any case LGTM
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel