Merge commit '345a96c327e8f2a8077189af9f5e8d2b3f4ad5fe'
authorMichael Niedermayer <michaelni@gmx.at>
Sun, 13 Apr 2014 01:54:11 +0000 (03:54 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Sun, 13 Apr 2014 01:54:11 +0000 (03:54 +0200)
* commit '345a96c327e8f2a8077189af9f5e8d2b3f4ad5fe':
  tiffdec: remove an unneeded variable

Conflicts:
libavcodec/tiff.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/tiff.c

@@@ -579,31 -296,25 +579,30 @@@ static int init_image(TiffContext *s, T
      return 0;
  }
  
 -static int tiff_decode_tag(TiffContext *s)
 +static void set_sar(TiffContext *s, unsigned tag, unsigned num, unsigned den)
 +{
 +    int offset = tag == TIFF_YRES ? 2 : 0;
 +    s->res[offset++] = num;
 +    s->res[offset]   = den;
 +    if (s->res[0] && s->res[1] && s->res[2] && s->res[3])
 +        av_reduce(&s->avctx->sample_aspect_ratio.num, &s->avctx->sample_aspect_ratio.den,
 +                  s->res[2] * (uint64_t)s->res[1], s->res[0] * (uint64_t)s->res[3], INT32_MAX);
 +}
 +
 +static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
  {
 -    unsigned tag, type, count, off, value = 0;
 +    unsigned tag, type, count, off, value = 0, value2 = 0;
      int i, start;
-     uint32_t *pal;
 +    int j, k, pos;
 +    int ret;
 +    double *dp;
  
 -    if (bytestream2_get_bytes_left(&s->gb) < 12)
 -        return AVERROR_INVALIDDATA;
 -    tag   = tget_short(&s->gb, s->le);
 -    type  = tget_short(&s->gb, s->le);
 -    count = tget_long(&s->gb, s->le);
 -    off   = tget_long(&s->gb, s->le);
 -    start = bytestream2_tell(&s->gb);
 -
 -    if (type == 0 || type >= FF_ARRAY_ELEMS(type_sizes)) {
 -        av_log(s->avctx, AV_LOG_DEBUG, "Unknown tiff type (%u) encountered\n",
 -               type);
 -        return 0;
 +    ret = ff_tread_tag(&s->gb, s->le, &tag, &type, &count, &start);
 +    if (ret < 0) {
 +        goto end;
      }
  
 +    off = bytestream2_tell(&s->gb);
      if (count == 1) {
          switch (type) {
          case TIFF_BYTE:
          if (count / 3 > 256 ||
              bytestream2_get_bytes_left(&s->gb) < count / 3 * off * 3)
              return AVERROR_INVALIDDATA;
 +
+         pal_gb[0] = pal_gb[1] = pal_gb[2] = s->gb;
+         bytestream2_skip(&pal_gb[1], count / 3 * off);
+         bytestream2_skip(&pal_gb[2], count / 3 * off * 2);
++
          off = (type_sizes[type] - 1) << 3;
-         for (k = 2; k >= 0; k--) {
-             for (i = 0; i < count / 3; i++) {
-                 if (k == 2)
-                     pal[i] = 0xFFU << 24;
-                 j =  (ff_tget(&s->gb, type, s->le) >> off) << (k * 8);
-                 pal[i] |= j;
-             }
+         for (i = 0; i < count / 3; i++) {
+             uint32_t p = 0xFF000000;
 -            p |= (tget(&pal_gb[0], type, s->le) >> off) << 16;
 -            p |= (tget(&pal_gb[1], type, s->le) >> off) << 8;
 -            p |=  tget(&pal_gb[2], type, s->le) >> off;
++            p |= (ff_tget(&pal_gb[0], type, s->le) >> off) << 16;
++            p |= (ff_tget(&pal_gb[1], type, s->le) >> off) << 8;
++            p |=  ff_tget(&pal_gb[2], type, s->le) >> off;
+             s->palette[i] = p;
          }
          s->palette_is_set = 1;
          break;