]> git.sesse.net Git - ffmpeg/commitdiff
Merge commit '5de64bb34d68d6c224dca90003172d7a27958825'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 4 Feb 2014 14:08:29 +0000 (15:08 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 4 Feb 2014 14:09:02 +0000 (15:09 +0100)
* commit '5de64bb34d68d6c224dca90003172d7a27958825':
  utvideoenc: Add support for the new BT.709 FourCCs for YCbCr

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

diff --combined libavcodec/utvideoenc.c
index f6e4e7e35888fb3ee7507138aeb80b16ad3a94d7,47a4f3a25f784cca1ea69eb66236ccacb19ee826..ab2cfaaa034c2c9bf5ad20cfe9c0c50fcb24792d
@@@ -2,20 -2,20 +2,20 @@@
   * Ut Video encoder
   * Copyright (c) 2012 Jan Ekström
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * FFmpeg is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * FFmpeg is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   *
   * You should have received a copy of the GNU Lesser General Public
 - * License along with Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -83,7 -83,10 +83,10 @@@ static av_cold int utvideo_encode_init(
              return AVERROR_INVALIDDATA;
          }
          c->planes        = 3;
-         avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
+         if (avctx->colorspace == AVCOL_SPC_BT709)
+             avctx->codec_tag = MKTAG('U', 'L', 'H', '0');
+         else
+             avctx->codec_tag = MKTAG('U', 'L', 'Y', '0');
          original_format  = UTVIDEO_420;
          break;
      case AV_PIX_FMT_YUV422P:
              return AVERROR_INVALIDDATA;
          }
          c->planes        = 3;
-         avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
+         if (avctx->colorspace == AVCOL_SPC_BT709)
+             avctx->codec_tag = MKTAG('U', 'L', 'H', '2');
+         else
+             avctx->codec_tag = MKTAG('U', 'L', 'Y', '2');
          original_format  = UTVIDEO_422;
          break;
      default:
@@@ -363,7 -369,6 +369,7 @@@ static int encode_plane(AVCodecContext 
      uint32_t offset = 0, slice_len = 0;
      int      i, sstart, send = 0;
      int      symbol;
 +    int      ret;
  
      /* Do prediction / make planes */
      switch (c->frame_pred) {
          /* If non-zero count is found, see if it matches width * height */
          if (counts[symbol]) {
              /* Special case if only one symbol was used */
 -            if (counts[symbol] == width * height) {
 +            if (counts[symbol] == width * (int64_t)height) {
                  /*
                   * Write a zero for the single symbol
                   * used in the plane, else 0xFF.
      }
  
      /* Calculate huffman lengths */
 -    ff_huff_gen_len_table(lengths, counts);
 +    if ((ret = ff_huff_gen_len_table(lengths, counts, 256)) < 0)
 +        return ret;
  
      /*
       * Write the plane's header into the output packet:
@@@ -505,17 -509,22 +511,17 @@@ static int utvideo_encode_frame(AVCodec
      int i, ret = 0;
  
      /* Allocate a new packet if needed, and set it to the pointer dst */
 -    ret = ff_alloc_packet(pkt, (256 + 4 * c->slices + width * height) *
 -                          c->planes + 4);
 +    ret = ff_alloc_packet2(avctx, pkt, (256 + 4 * c->slices + width * height) *
 +                           c->planes + 4);
  
 -    if (ret < 0) {
 -        av_log(avctx, AV_LOG_ERROR,
 -               "Error allocating the output packet, or the provided packet "
 -               "was too small.\n");
 +    if (ret < 0)
          return ret;
 -    }
  
      dst = pkt->data;
  
      bytestream2_init_writer(&pb, dst, pkt->size);
  
 -    av_fast_malloc(&c->slice_bits, &c->slice_bits_size,
 -                   width * height + FF_INPUT_BUFFER_PADDING_SIZE);
 +    av_fast_padded_malloc(&c->slice_bits, &c->slice_bits_size, width * height);
  
      if (!c->slice_bits) {
          av_log(avctx, AV_LOG_ERROR, "Cannot allocate temporary buffer 2.\n");