mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-02 20:35:37 +02:00
mmal: Fix AVBufferRef usage
AVBufferRef.data and AVPacket.data don't need to have the same value. AVPacket could point anywhere into the buffer. Likewise, the sizes don't need to be the same. Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
This commit is contained in:
parent
49623f5319
commit
a9b8c638cf
@ -433,17 +433,20 @@ static int ffmmal_add_packet(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
if (avpkt->size) {
|
if (avpkt->size) {
|
||||||
if (avpkt->buf) {
|
if (avpkt->buf) {
|
||||||
buf = av_buffer_ref(avpkt->buf);
|
buf = av_buffer_ref(avpkt->buf);
|
||||||
|
size = avpkt->size;
|
||||||
|
data = avpkt->data;
|
||||||
} else {
|
} else {
|
||||||
buf = av_buffer_alloc(avpkt->size);
|
buf = av_buffer_alloc(avpkt->size);
|
||||||
if (buf)
|
if (buf) {
|
||||||
memcpy(buf->data, avpkt->data, avpkt->size);
|
memcpy(buf->data, avpkt->data, avpkt->size);
|
||||||
|
size = buf->size;
|
||||||
|
data = buf->data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
ret = AVERROR(ENOMEM);
|
ret = AVERROR(ENOMEM);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
size = buf->size;
|
|
||||||
data = buf->data;
|
|
||||||
if (!is_extradata)
|
if (!is_extradata)
|
||||||
ctx->packets_sent++;
|
ctx->packets_sent++;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user