[FFmpeg-cvslog] avcodec/avpacket: Refactoring copy_side_data into a separate function
Vignesh Venkatasubramanian
git at videolan.org
Tue May 14 22:52:03 CEST 2013
ffmpeg | branch: master | Vignesh Venkatasubramanian <vigneshv at google.com> | Wed May 8 16:59:31 2013 -0700| [48de04f4ec08140c129c0f7ae721bb5aa0d17aca] | committer: Michael Niedermayer
avcodec/avpacket: Refactoring copy_side_data into a separate function
Refactoring copy_side_data into a separate function so that it can be called
in cases where side data needs to be duplicated.
Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=48de04f4ec08140c129c0f7ae721bb5aa0d17aca
---
libavcodec/avcodec.h | 7 +++++++
libavcodec/avpacket.c | 19 +++++++++++++++----
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 21e5856..8f6a722 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -3484,6 +3484,13 @@ int av_dup_packet(AVPacket *pkt);
int av_copy_packet(AVPacket *dst, AVPacket *src);
/**
+ * Copy packet side data
+ *
+ * @return 0 on success, negative AVERROR on fail
+ */
+int av_copy_packet_side_data(AVPacket *dst, AVPacket *src);
+
+/**
* Free a packet.
*
* @param pkt packet to free
diff --git a/libavcodec/avpacket.c b/libavcodec/avpacket.c
index 92f4fdf..198365e 100644
--- a/libavcodec/avpacket.c
+++ b/libavcodec/avpacket.c
@@ -199,13 +199,24 @@ static int copy_packet_data(AVPacket *pkt, AVPacket *src, int dup)
if (pkt->side_data_elems && dup)
pkt->side_data = src->side_data;
if (pkt->side_data_elems && !dup) {
- int i;
+ return av_copy_packet_side_data(pkt, src);
+ }
+ return 0;
+
+failed_alloc:
+ av_destruct_packet(pkt);
+ return AVERROR(ENOMEM);
+}
+int av_copy_packet_side_data(AVPacket *pkt, AVPacket *src)
+{
+ if (src->side_data_elems) {
+ int i;
DUP_DATA(pkt->side_data, src->side_data,
- pkt->side_data_elems * sizeof(*pkt->side_data), 0, ALLOC_MALLOC);
+ src->side_data_elems * sizeof(*src->side_data), 0, ALLOC_MALLOC);
memset(pkt->side_data, 0,
- pkt->side_data_elems * sizeof(*pkt->side_data));
- for (i = 0; i < pkt->side_data_elems; i++) {
+ src->side_data_elems * sizeof(*src->side_data));
+ for (i = 0; i < src->side_data_elems; i++) {
DUP_DATA(pkt->side_data[i].data, src->side_data[i].data,
src->side_data[i].size, 1, ALLOC_MALLOC);
pkt->side_data[i].size = src->side_data[i].size;
More information about the ffmpeg-cvslog
mailing list