Commit ba40b352 authored by Mats Peterson's avatar Mats Peterson Committed by Michael Niedermayer

lavf/utils: Normalize AVPacket.data to native endian in ff_get_packet_palette()

Signed-off-by: 's avatarMichael Niedermayer <michael@niedermayer.cc>
parent 21234c83
...@@ -588,9 +588,12 @@ int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecContext *en ...@@ -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. * 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 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 */ #endif /* AVFORMAT_INTERNAL_H */
...@@ -4782,18 +4782,27 @@ int ff_standardize_creation_time(AVFormatContext *s) ...@@ -4782,18 +4782,27 @@ int ff_standardize_creation_time(AVFormatContext *s)
return ret; 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; int size;
*palette = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size); side_data = av_packet_get_side_data(pkt, AV_PKT_DATA_PALETTE, &size);
if (*palette && size != AVPALETTE_SIZE) { if (side_data) {
av_log(s, AV_LOG_ERROR, "Invalid palette side data\n"); if (size != AVPALETTE_SIZE) {
return AVERROR_INVALIDDATA; 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) if (ret == CONTAINS_PAL) {
*palette = pkt->data + pkt->size - AVPALETTE_SIZE; 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; return 0;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment