[FFmpeg-devel] [PATCH]Write TIFFTAG_EXTRASAMPLES for pix_fmts containing transparency

Michael Niedermayer michaelni at gmx.at
Thu Aug 30 22:06:24 CEST 2012


On Wed, Aug 29, 2012 at 03:43:11PM +0200, Carl Eugen Hoyos wrote:
> Hi!
> 
> The tiff specification requires the TIFFTAG_EXTRASAMPLES tag to be written if 
> SamplesPerPixel is larger than what PhotometricInterpretation would indicate.
> 
> Please review, Carl Eugen

>  tiffenc.c |    6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 2f4034ebdd9a9f8d663b20b1e948ab425de0d9b4  patchtiffalpha.diff
> diff --git a/libavcodec/tiffenc.c b/libavcodec/tiffenc.c
> index 883d6fb..dc4c704 100644
> --- a/libavcodec/tiffenc.c
> +++ b/libavcodec/tiffenc.c
> @@ -248,7 +248,7 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
>      uint32_t res[2] = { s->dpi, 1 };        // image resolution (72/1)
>      uint16_t bpp_tab[4];
>      int ret = -1;
> -    int is_yuv = 0;
> +    int is_yuv = 0, alpha = 0;
>      int shift_h, shift_v;
>  
>      *p = *pict;
> @@ -265,12 +265,14 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
>      case PIX_FMT_RGBA64LE:
>      case PIX_FMT_RGB48LE:
>      case PIX_FMT_RGBA:
> +        alpha = 1;
>      case PIX_FMT_RGB24:
>          s->photometric_interpretation = 2;
>          break;
>      case PIX_FMT_GRAY8:
>          avctx->bits_per_coded_sample = 0x28;
>      case PIX_FMT_GRAY8A:
> +        alpha = avctx->pix_fmt == PIX_FMT_GRAY8A;
>      case PIX_FMT_GRAY16LE:
>          s->photometric_interpretation = 1;
>          break;
> @@ -451,6 +453,8 @@ static int encode_frame(AVCodecContext * avctx, AVPacket *pkt,
>          }
>          add_entry(s, TIFF_PAL, TIFF_SHORT, 256 * 3, pal);
>      }
> +    if (alpha)
> +        add_entry1(s,TIFF_EXTRASAMPLES,      TIFF_SHORT,            2);

LGTM if fate passes, but if it does maybe a test should be added
for this

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

it is not once nor twice but times without number that the same ideas make
their appearance in the world. -- Aristotle
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120830/ae72a429/attachment.asc>


More information about the ffmpeg-devel mailing list