dpcm: decode directly to the user-provided AVFrame
This commit is contained in:
parent
9b28e58357
commit
b878867128
@ -44,7 +44,6 @@
|
|||||||
#include "mathops.h"
|
#include "mathops.h"
|
||||||
|
|
||||||
typedef struct DPCMContext {
|
typedef struct DPCMContext {
|
||||||
AVFrame frame;
|
|
||||||
int16_t roq_square_array[256];
|
int16_t roq_square_array[256];
|
||||||
int sample[2]; ///< previous sample (for SOL_DPCM)
|
int sample[2]; ///< previous sample (for SOL_DPCM)
|
||||||
const int8_t *sol_table; ///< delta table for SOL_DPCM
|
const int8_t *sol_table; ///< delta table for SOL_DPCM
|
||||||
@ -163,9 +162,6 @@ static av_cold int dpcm_decode_init(AVCodecContext *avctx)
|
|||||||
else
|
else
|
||||||
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
|
||||||
|
|
||||||
avcodec_get_frame_defaults(&s->frame);
|
|
||||||
avctx->coded_frame = &s->frame;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,6 +171,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
{
|
{
|
||||||
int buf_size = avpkt->size;
|
int buf_size = avpkt->size;
|
||||||
DPCMContext *s = avctx->priv_data;
|
DPCMContext *s = avctx->priv_data;
|
||||||
|
AVFrame *frame = data;
|
||||||
int out = 0, ret;
|
int out = 0, ret;
|
||||||
int predictor[2];
|
int predictor[2];
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
@ -210,12 +207,12 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get output buffer */
|
/* get output buffer */
|
||||||
s->frame.nb_samples = out / avctx->channels;
|
frame->nb_samples = out / avctx->channels;
|
||||||
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
|
if ((ret = ff_get_buffer(avctx, frame)) < 0) {
|
||||||
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
output_samples = (int16_t *)s->frame.data[0];
|
output_samples = (int16_t *)frame->data[0];
|
||||||
samples_end = output_samples + out;
|
samples_end = output_samples + out;
|
||||||
|
|
||||||
switch(avctx->codec->id) {
|
switch(avctx->codec->id) {
|
||||||
@ -295,7 +292,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
}
|
}
|
||||||
case AV_CODEC_ID_SOL_DPCM:
|
case AV_CODEC_ID_SOL_DPCM:
|
||||||
if (avctx->codec_tag != 3) {
|
if (avctx->codec_tag != 3) {
|
||||||
uint8_t *output_samples_u8 = s->frame.data[0],
|
uint8_t *output_samples_u8 = frame->data[0],
|
||||||
*samples_end_u8 = output_samples_u8 + out;
|
*samples_end_u8 = output_samples_u8 + out;
|
||||||
while (output_samples_u8 < samples_end_u8) {
|
while (output_samples_u8 < samples_end_u8) {
|
||||||
int n = bytestream2_get_byteu(&gb);
|
int n = bytestream2_get_byteu(&gb);
|
||||||
@ -322,8 +319,7 @@ static int dpcm_decode_frame(AVCodecContext *avctx, void *data,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*got_frame_ptr = 1;
|
*got_frame_ptr = 1;
|
||||||
*(AVFrame *)data = s->frame;
|
|
||||||
|
|
||||||
return avpkt->size;
|
return avpkt->size;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user