[FFmpeg-cvslog] lavf/utils: Add ff_get_packet_palette()
Mats Peterson
git at videolan.org
Wed Mar 2 18:14:50 CET 2016
ffmpeg | branch: master | Mats Peterson <matsp888 at yahoo.com> | Wed Mar 2 03:14:05 2016 +0100| [2be0366a7f5de926efac5a412268c824a6acbddf] | committer: Michael Niedermayer
lavf/utils: Add ff_get_packet_palette()
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=2be0366a7f5de926efac5a412268c824a6acbddf
---
libavformat/internal.h | 12 ++++++++++++
libavformat/utils.c | 16 ++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index bc6a6c2..8e06655 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -573,4 +573,16 @@ int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int
*/
int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *enc, int expected_stride);
+/**
+ * Retrieves the palette from a packet, either from side data, or
+ * appended to the video data in the packet itself (raw video only).
+ * It is commonly used after a call to ff_reshuffle_raw_rgb().
+ *
+ * Use 0 for the ret parameter to check for side data only.
+ *
+ * @param pkt pointer to the packet before calling ff_reshuffle_raw_rgb()
+ * @param ret return value from ff_reshuffle_raw_rgb(), or 0
+ */
+int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette);
+
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index fe2916f..771e878 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4759,3 +4759,19 @@ int ff_parse_creation_time_metadata(AVFormatContext *s, int64_t *timestamp, int
}
return 0;
}
+
+int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette)
+{
+ int size;
+
+ *palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
+ if (*palette && size != AVPALETTE_SIZE) {
+ av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+ return AVERROR_INVALIDDATA;
+ }
+
+ if (!*palette && ret == CONTAINS_PAL)
+ *palette = pkt->data + pkt->size - AVPALETTE_SIZE;
+
+ return 0;
+}
More information about the ffmpeg-cvslog
mailing list