diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-05-06 16:04:26 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2022-05-10 07:29:32 +0200 |
commit | 533836b8e0e5693b3d3e8403666ce216687d51b3 (patch) | |
tree | 5ce24749b49255d4055ab6bb3519d1f7a470cce0 /libavformat/rawutils.c | |
parent | ba49acf143743bc9480566a52e94030cf38bfc75 (diff) |
avformat/utils: Move ff_get_packet_palette() to rawutils.c
ff_get_packet_palette() and ff_reshuffle_raw_rgb() belong together:
E.g. the former takes the return value of the latter as argument.
So move ff_get_packet_palette() to rawutils.c (which consists solely
of ff_reshuffle_raw_rgb()).
Also add a separate header for these two functions.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Diffstat (limited to 'libavformat/rawutils.c')
-rw-r--r-- | libavformat/rawutils.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/libavformat/rawutils.c b/libavformat/rawutils.c index 996412adb9..e44c946d47 100644 --- a/libavformat/rawutils.c +++ b/libavformat/rawutils.c @@ -19,8 +19,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "libavutil/intreadwrite.h" +#include "libavcodec/packet.h" #include "avformat.h" -#include "internal.h" +#include "rawutils.h" int ff_reshuffle_raw_rgb(AVFormatContext *s, AVPacket **ppkt, AVCodecParameters *par, int expected_stride) { @@ -65,3 +67,27 @@ fail: return ret; } + +int ff_get_packet_palette(AVFormatContext *s, AVPacket *pkt, int ret, uint32_t *palette) +{ + uint8_t *side_data; + size_t size; + + 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 (ret == CONTAINS_PAL) { + for (int i = 0; i < AVPALETTE_COUNT; i++) + palette[i] = AV_RL32(pkt->data + pkt->size - AVPALETTE_SIZE + i*4); + return 1; + } + + return 0; +} |