[FFmpeg-devel] [PATCH] IFF: Add the HAM stuff
Michael Niedermayer
michaelni
Wed May 26 19:28:24 CEST 2010
On Wed, May 26, 2010 at 03:40:22PM +0200, Sebastian Vater wrote:
> Sebastian Vater a ?crit :
> > Oops, sorry...extract_header in both decode_frame's should be before
> > get_buffer...Fixed!
> >
> > Please review this one instead of the previous one!
> >
> >
>
> New HAM patch taking the latest changes of the byterun1 error checking
> patch and libavfilter enabled crash patch into account.
>
> Otherwise than that it's the same.
>
> --
>
> Best regards,
> :-) Basty/CDGS (-:
>
> libavcodec/iff.c | 258 +++++++++++++++++++++++++++++++++++++++++++++++++++---
> libavcodec/iff.h | 18 +++
> libavformat/iff.c | 78 ++++++++++++++--
> 3 files changed, 333 insertions(+), 21 deletions(-)
> 1dc7970de43abdf3b2c12f58afcc5b27990c73c7 iff-ham-support.patch
> diff --git a/libavcodec/iff.c b/libavcodec/iff.c
> index 841f577..431a981 100644
> --- a/libavcodec/iff.c
> +++ b/libavcodec/iff.c
> @@ -30,11 +30,53 @@
> #include "get_bits.h"
> #include "iff.h"
>
> +// TODO: masking bits
> +typedef enum {
> + MASK_NONE,
> + MASK_HAS_MASK,
> + MASK_HAS_TRANSPARENT_COLOR,
> + MASK_LASSO
> +} mask_type;
> +
> +/**
> + * Gets the actual extradata after video preperties which contains
> + * the raw CMAP palette data beyond the IFF extra context.
> + */
> +#define GET_PALETTE_DATA(x) ((uint8_t *) (x)->extradata + AV_RB16((x)->extradata))
> +
> +/**
> + * Gets the size of CMAP palette data beyond the IFF extra context.
> + * Please note that any value < 2 of IFF extra context or
> + * raw extradata < 0 is considered as illegal extradata.
> + */
> +#define GET_PALETTE_SIZE(x) ((x)->extradata_size - AV_RB16((x)->extradata))
> +
> +/**
> + * Gets the actual packet data after video properties which contains
> + * the raw data beyond the IFF extra context.
> + */
> +#define GET_PACKET_DATA(x) ((uint8_t *) (x)->data + AV_RB16((x)->data))
> +
> +/**
> + * Gets the size of raw data beyond the IFF extra context. Please note
> + * that any value < 2 of either IFF extra context or raw packet data
> + * is considered as an illegal packet.
> + */
> +#define GET_PACKET_SIZE(x) ((x)->size - AV_RB16((x)->data))
i think these macros are ugly
it seems to me that fields in IffContext or local variables where
possible would be nicer
> +
> typedef struct {
> AVFrame frame;
> int planesize;
> uint8_t * planebuf;
> int init; // 1 if buffer and palette data already initialized, 0 otherwise
> + uint8_t * ham_buf; ///< temporary buffer for planar to chunky conversation
> + uint32_t *ham_palbuf; ///< HAM decode table
> + unsigned compression; ///< delta compression method used
> + unsigned bpp; ///< bits per plane to decode (differs from bits_per_coded_sample if HAM)
> + unsigned ham; ///< 0 if non-HAM or number of hold bits (6 for bpp > 6, 4 otherwise)
> + unsigned flags; ///< 1 for EHB, 0 is no extra half darkening
> + unsigned transparency; ///< TODO: transparency color index in palette
> + unsigned masking; ///< TODO: masking method used
> } IffContext;
>
> #define LUT8_PART(plane, v) \
> @@ -122,6 +164,7 @@ static av_always_inline uint32_t gray2rgb(const uint32_t x) {
> int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
> {
> int count, i;
> + const uint8_t *const extradata = GET_PALETTE_DATA(avctx);
>
> if (avctx->bits_per_coded_sample > 8) {
> av_log(avctx, AV_LOG_ERROR, "bit_per_coded_sample > 8 not supported\n");
> @@ -130,10 +173,10 @@ int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
>
> count = 1 << avctx->bits_per_coded_sample;
> // If extradata is smaller than actually needed, fill the remaining with black.
> - count = FFMIN(avctx->extradata_size / 3, count);
> + count = FFMIN(GET_PALETTE_SIZE(avctx) / 3, count);
> if (count) {
> for (i=0; i < count; i++) {
> - pal[i] = 0xFF000000 | AV_RB24( avctx->extradata + i*3 );
> + pal[i] = 0xFF000000 | AV_RB24(extradata + i*3);
> }
> } else { // Create gray-scale color palette for bps < 8
> count = 1 << avctx->bits_per_coded_sample;
> @@ -145,15 +188,123 @@ int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal)
> return 0;
> }
>
> +/**
> + * Extracts the IFF extra context and updates internal
> + * decoder structures.
> + *
> + * @param avctx the AVCodecContext where to extract extra context to
> + * @param avpkt the AVPacket to extract extra context from or NULL to use avctx
> + * @return 0 in case of success, a negative error code otherwise
> + */
> +static int extract_header(AVCodecContext *const avctx,
> + const AVPacket *const avpkt) {
isnt const char *data, int size simpler than this and the if() below?
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
The greatest way to live with honor in this world is to be what we pretend
to be. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100526/4e4a7088/attachment.pgp>
More information about the ffmpeg-devel
mailing list