[FFmpeg-cvslog] lavf/utils: Normalize AVPacket.data to native endian in ff_get_packet_palette()
Mats Peterson
git at videolan.org
Fri Mar 4 04:37:36 CET 2016
ffmpeg | branch: master | Mats Peterson <matsp888 at yahoo.com> | Thu Mar 3 08:25:58 2016 +0100| [ba40b3520d91a3bff1637cbff54562e03b79bc2d] | committer: Michael Niedermayer
lavf/utils: Normalize AVPacket.data to native endian in ff_get_packet_palette()
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ba40b3520d91a3bff1637cbff54562e03b79bc2d
---
libavformat/internal.h | 7 +++++--
libavformat/utils.c | 23 ++++++++++++++++-------
2 files changed, 21 insertions(+), 9 deletions(-)
diff --git a/libavformat/internal.h b/libavformat/internal.h
index 63e0632..37a8591 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -588,9 +588,12 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *en
*
* 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 pkt pointer to packet before calling ff_reshuffle_raw_rgb()
* @param ret return value from ff_reshuffle_raw_rgb(), or 0
+ * @param palette pointer to palette buffer
+ * @return negative error code or
+ * 1 if the packet has a palette, else 0
*/
-int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette);
+int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette);
#endif /* AVFORMAT_INTERNAL_H */
diff --git a/libavformat/utils.c b/libavformat/utils.c
index 85702dd..7c14725 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4782,18 +4782,27 @@ int ff_standardize_creation_time(AVFormatContext *s)
return ret;
}
-int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, const uint8_t **palette)
+int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette)
{
+ uint8_t *side_data;
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;
+ side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
+ if (side_data) {
+ if (size != AVPALETTE_SIZE) {
+ av_log(s, AV_LOG_ERROR, "Invalid palette side data\n");
+ return AVERROR_INVALIDDATA;
+ }
+ memcpy(palette, side_data, AVPALETTE_SIZE);
+ return 1;
}
- if (!*palette && ret == CONTAINS_PAL)
- *palette = pkt->data + pkt->size - AVPALETTE_SIZE;
+ if (ret == CONTAINS_PAL) {
+ int i;
+ for (i = 0; i < AVPALETTE_COUNT; i++)
+ palette[i] = AV_RL32(pkt->data + pkt->size - AVPALETTE_SIZE + i*4);
+ return 1;
+ }
return 0;
}
More information about the ffmpeg-cvslog
mailing list