diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2012-01-17 01:40:45 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2012-01-17 02:37:30 +0100 |
commit | 67f5650a78de2567c58dbd7545434cc6d3ef9b7e (patch) | |
tree | 34b08ed769cd7a1f071bf9ff4eca1348481c0bf1 /libavcodec/pcm.c | |
parent | 905c4dc2b0d564e1b9b6bc6eeca0b8915b81cd8c (diff) | |
parent | 9e12002f114d7e0b0ef69519518cdc0391e5e198 (diff) | |
download | ffmpeg-67f5650a78de2567c58dbd7545434cc6d3ef9b7e.tar.gz |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
rv34: add NEON rv34_idct_add
rv34: 1-pass inter MB reconstruction
add SMJPEG muxer
avformat: split out common SMJPEG code
pictordec: Use bytestream2 functions
avconv: use avcodec_encode_audio2()
pcmenc: use AVCodec.encode2()
avcodec: bump minor version and add APIChanges for the new audio encoding API
avcodec: Add avcodec_encode_audio2() as replacement for avcodec_encode_audio()
avcodec: add a public function, avcodec_fill_audio_frame().
rv34: Intra 16x16 handling
rv34: Inter/intra MB code split
Conflicts:
Changelog
libavcodec/avcodec.h
libavcodec/pictordec.c
libavcodec/utils.c
libavcodec/version.h
libavcodec/x86/rv34dsp.asm
libavformat/version.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/pcm.c')
-rw-r--r-- | libavcodec/pcm.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 3609c3b0d9..650003793c 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "libavutil/common.h" /* for av_reverse */ #include "bytestream.h" +#include "internal.h" #include "pcm_tablegen.h" #define MAX_CHANNELS 64 @@ -77,10 +78,10 @@ static av_cold int pcm_encode_close(AVCodecContext *avctx) bytestream_put_##endian(&dst, v); \ } -static int pcm_encode_frame(AVCodecContext *avctx, - unsigned char *frame, int buf_size, void *data) +static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr) { - int n, sample_size, v; + int n, sample_size, v, ret; const short *samples; unsigned char *dst; const uint8_t *srcu8; @@ -91,9 +92,14 @@ static int pcm_encode_frame(AVCodecContext *avctx, const uint32_t *samples_uint32_t; sample_size = av_get_bits_per_sample(avctx->codec->id)/8; - n = buf_size / sample_size; - samples = data; - dst = frame; + n = frame->nb_samples * avctx->channels; + samples = (const short *)frame->data[0]; + + if ((ret = ff_alloc_packet(avpkt, n * sample_size))) { + av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); + return ret; + } + dst = avpkt->data; switch(avctx->codec->id) { case CODEC_ID_PCM_U32LE: @@ -130,7 +136,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, ENCODE(uint16_t, be16, samples, dst, n, 0, 0x8000) break; case CODEC_ID_PCM_S8: - srcu8= data; + srcu8 = frame->data[0]; for(;n>0;n--) { v = *srcu8++; *dst++ = v - 128; @@ -186,9 +192,10 @@ static int pcm_encode_frame(AVCodecContext *avctx, default: return -1; } - //avctx->frame_size = (dst - frame) / (sample_size * avctx->channels); - return dst - frame; + avpkt->size = frame->nb_samples * avctx->channels * sample_size; + *got_packet_ptr = 1; + return 0; } typedef struct PCMDecode { @@ -474,8 +481,9 @@ AVCodec ff_ ## name_ ## _encoder = { \ .type = AVMEDIA_TYPE_AUDIO, \ .id = id_, \ .init = pcm_encode_init, \ - .encode = pcm_encode_frame, \ + .encode2 = pcm_encode_frame, \ .close = pcm_encode_close, \ + .capabilities = CODEC_CAP_VARIABLE_FRAME_SIZE, \ .sample_fmts = (const enum AVSampleFormat[]){sample_fmt_,AV_SAMPLE_FMT_NONE}, \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ } |