Commit 47d2ddca authored by Baptiste Coudurier's avatar Baptiste Coudurier

Fix qdm2 decoder packet handling to match the api

Originally committed as revision 25767 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 5878d5bd
...@@ -1883,7 +1883,7 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx) ...@@ -1883,7 +1883,7 @@ static av_cold int qdm2_decode_close(AVCodecContext *avctx)
} }
static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) static int qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
{ {
int ch, i; int ch, i;
const int frame_size = (q->frame_size * q->channels); const int frame_size = (q->frame_size * q->channels);
...@@ -1919,7 +1919,7 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) ...@@ -1919,7 +1919,7 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) { if (!q->has_errors && q->sub_packet_list_C[0].packet != NULL) {
SAMPLES_NEEDED_2("has errors, and C list is not empty") SAMPLES_NEEDED_2("has errors, and C list is not empty")
return; return -1;
} }
} }
...@@ -1940,6 +1940,8 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out) ...@@ -1940,6 +1940,8 @@ static void qdm2_decode (QDM2Context *q, const uint8_t *in, int16_t *out)
out[i] = value; out[i] = value;
} }
return 0;
} }
...@@ -1950,25 +1952,26 @@ static int qdm2_decode_frame(AVCodecContext *avctx, ...@@ -1950,25 +1952,26 @@ static int qdm2_decode_frame(AVCodecContext *avctx,
const uint8_t *buf = avpkt->data; const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size; int buf_size = avpkt->size;
QDM2Context *s = avctx->priv_data; QDM2Context *s = avctx->priv_data;
int16_t *out = data;
int i;
if(!buf) if(!buf)
return 0; return 0;
if(buf_size < s->checksum_size) if(buf_size < s->checksum_size)
return -1; return -1;
*data_size = s->channels * s->frame_size * sizeof(int16_t);
av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n", av_log(avctx, AV_LOG_DEBUG, "decode(%d): %p[%d] -> %p[%d]\n",
buf_size, buf, s->checksum_size, data, *data_size); buf_size, buf, s->checksum_size, data, *data_size);
qdm2_decode(s, buf, data); for (i = 0; i < 16; i++) {
if (qdm2_decode(s, buf, out) < 0)
// reading only when next superblock found return -1;
if (s->sub_packet == 0) { out += s->channels * s->frame_size;
return s->checksum_size;
} }
return 0; *data_size = (uint8_t*)out - (uint8_t*)data;
return buf_size;
} }
AVCodec qdm2_decoder = AVCodec qdm2_decoder =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment