--
Mats Peterson
http://matsp888.no-ip.org/~mats/
>From 47d09853998e30e486b0069223a90d80e7742499 Mon Sep 17 00:00:00 2001
From: Mats Peterson <matsp...@yahoo.com>
Date: Fri, 4 Mar 2016 02:57:59 +0100
Subject: [PATCH v6 4/4] lavf/utils: Normalize AVPacket.data to native endian

---
 libavformat/internal.h |    5 +++--
 libavformat/utils.c    |   16 ++++++++++++----
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/internal.h b/libavformat/internal.h
index 63e0632..fe95009 100644
--- a/libavformat/internal.h
+++ b/libavformat/internal.h
@@ -588,9 +588,10 @@ 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 pointer, which will be NULL if no palette found
  */
-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..e66abcc 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -4782,18 +4782,26 @@ 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)
 {
     int size;
 
-    *palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
+    *palette = (uint32_t *)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;
+    if (!*palette && ret == CONTAINS_PAL) {
+        uint8_t *pkt_pal = pkt->data + pkt->size - AVPALETTE_SIZE;
+        int i;
+        for (i = 0; i < AVPALETTE_COUNT; i++) {
+            uint8_t *p8 = pkt_pal + 4*i;
+            uint32_t *p32 = (uint32_t *)p8;
+            *p32 = AV_RL32(p8);
+        }
+        *palette = (uint32_t *)pkt_pal;
+    }
 
     return 0;
 }
-- 
1.7.10.4

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to