path: root/common
diff options
authorwm4 <wm4@nowhere>2014-08-24 17:45:28 +0200
committerwm4 <wm4@nowhere>2014-08-25 00:46:26 +0200
commit758f8f7bd46388cba9330ad47701c0ebacc2d963 (patch)
tree5fcecbf5218d13888af60251c8f8fd821c983cfd /common
parentef1c6e9295f40a4633685eeae3c12706f8290bb0 (diff)
demux: always use AVPacket
This is a simplification, because it lets us use the AVPacket functions, instead of handling the details manually. It also allows the libavcodec rawvideo decoder to use reference counting, so it doesn't have to memcpy() the full image data. The change in av_common.c enables this. This change is somewhat risky, because we rely on the following AVPacket implementation details and assumptions: - av_packet_ref() doesn't access the input padding, and just copies the data. By the API, AVPacket is always padded, and we violate this. The lavc implementation would have to go out of its way to make this a real problem, though. - We hope that the way we make the AVPacket refcountable in av_common.c is actually supported API-usage. It's hard to tell whether it is. Of course we still use our own "old" demux_packet struct, just so that libav* API usage is somewhat isolated.
Diffstat (limited to 'common')
1 files changed, 2 insertions, 0 deletions
diff --git a/common/av_common.c b/common/av_common.c
index e0a5da7726..cced1c0694 100644
--- a/common/av_common.c
+++ b/common/av_common.c
@@ -117,6 +117,8 @@ void mp_set_av_packet(AVPacket *dst, struct demux_packet *mpkt, AVRational *tb)
if (mpkt && mpkt->avpacket) {
dst->side_data = mpkt->avpacket->side_data;
dst->side_data_elems = mpkt->avpacket->side_data_elems;
+ if (dst->data == mpkt->avpacket->data)
+ dst->buf = mpkt->avpacket->buf;
if (mpkt && tb && tb->num > 0 && tb->den > 0)
dst->duration = mpkt->duration / av_q2d(*tb);