OSDN Git Service

Merge commit 'd92024f18fa3d69937cb2575f3a8bf973df02430'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 11 Mar 2014 20:05:34 +0000 (21:05 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 11 Mar 2014 20:05:34 +0000 (21:05 +0100)
* commit 'd92024f18fa3d69937cb2575f3a8bf973df02430':
  lavf: more correct printf format specifiers

Conflicts:
libavformat/asfdec.c
libavformat/cafdec.c
libavformat/dxa.c
libavformat/framecrcenc.c
libavformat/hnm.c
libavformat/iff.c
libavformat/mov.c
libavformat/mxfdec.c
libavformat/rmdec.c
libavformat/rpl.c
libavformat/smacker.c
libavformat/xmv.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
26 files changed:
1  2 
libavformat/apetag.c
libavformat/asfdec.c
libavformat/avidec.c
libavformat/bink.c
libavformat/cafdec.c
libavformat/crcenc.c
libavformat/dfa.c
libavformat/dxa.c
libavformat/electronicarts.c
libavformat/framecrcenc.c
libavformat/gxf.c
libavformat/hnm.c
libavformat/iff.c
libavformat/lxfdec.c
libavformat/matroskadec.c
libavformat/mov.c
libavformat/mvi.c
libavformat/mxfdec.c
libavformat/omadec.c
libavformat/rmdec.c
libavformat/rpl.c
libavformat/smacker.c
libavformat/smjpegdec.c
libavformat/spdifenc.c
libavformat/wtvdec.c
libavformat/xmv.c

Simple merge
@@@ -943,14 -923,14 +945,14 @@@ static int asf_get_packet(AVFormatConte
      // the following checks prevent overflows and infinite loops
      if (!packet_length || packet_length >= (1U << 29)) {
          av_log(s, AV_LOG_ERROR,
-                "invalid packet_length %d at:%"PRId64"\n",
+                "invalid packet_length %"PRIu32" at:%"PRId64"\n",
                 packet_length, avio_tell(pb));
 -        return -1;
 +        return AVERROR_INVALIDDATA;
      }
      if (padsize >= packet_length) {
          av_log(s, AV_LOG_ERROR,
-                "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
+                "invalid padsize %"PRIu32" at:%"PRId64"\n", padsize, avio_tell(pb));
 -        return -1;
 +        return AVERROR_INVALIDDATA;
      }
  
      asf->packet_timestamp = avio_rl32(pb);
      if (rsize > packet_length - padsize) {
          asf->packet_size_left = 0;
          av_log(s, AV_LOG_ERROR,
-                "invalid packet header length %d for pktlen %d-%d at %"PRId64"\n",
+                "invalid packet header length %d for pktlen %"PRIu32"-%"PRIu32" at %"PRId64"\n",
                 rsize, packet_length, padsize, avio_tell(pb));
 -        return -1;
 +        return AVERROR_INVALIDDATA;
      }
      asf->packet_size_left = packet_length - padsize - rsize;
      if (packet_length < asf->hdr.min_pktsize)
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
- #include <stdint.h>
+ #include <inttypes.h>
  
 +#include "libavutil/avassert.h"
  #include "libavutil/avstring.h"
  #include "libavutil/bswap.h"
 +#include "libavutil/opt.h"
  #include "libavutil/dict.h"
  #include "libavutil/internal.h"
  #include "libavutil/intreadwrite.h"
Simple merge
@@@ -285,8 -291,9 +287,9 @@@ static int read_header(AVFormatContext 
  
          default:
  #define _(x) ((x) >= ' ' ? (x) : ' ')
-             av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c), size %"PRId64"\n",
+             av_log(s, AV_LOG_WARNING,
 -                   "skipping CAF chunk: %08"PRIX32" (%"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8")\n",
 -                tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF));
++                   "skipping CAF chunk: %08"PRIX32" (%"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8"), size %"PRId64"\n",
 +                tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF), size);
  #undef _
          case MKBETAG('f','r','e','e'):
              if (size < 0)
Simple merge
Simple merge
@@@ -190,14 -189,12 +192,15 @@@ static int dxa_read_packet(AVFormatCont
              avio_read(s->pb, pal + 4, 768);
              break;
          case MKTAG('F', 'R', 'A', 'M'):
 -            avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
 +            if ((ret = avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4)) != DXA_EXTRA_SIZE - 4) {
 +                av_log(s, AV_LOG_ERROR, "failed reading dxa_extra\n");
 +                return ret < 0 ? ret : AVERROR_INVALIDDATA;
 +            }
              size = AV_RB32(buf + 5);
              if(size > 0xFFFFFF){
-                 av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
+                 av_log(s, AV_LOG_ERROR, "Frame size is too big: %"PRIu32"\n",
+                        size);
 -                return -1;
 +                return AVERROR_INVALIDDATA;
              }
              if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
                  return AVERROR(ENOMEM);
Simple merge
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include <inttypes.h>
  #include "libavutil/adler32.h"
 +#include "libavutil/avstring.h"
  #include "avformat.h"
  #include "internal.h"
  
@@@ -29,31 -30,8 +31,31 @@@ static int framecrc_write_packet(struc
      uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
      char buf[256];
  
-     snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08x",
 -    snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32"\n",
++    snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32,
               pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
 +    if (pkt->flags != AV_PKT_FLAG_KEY)
 +        av_strlcatf(buf, sizeof(buf), ", F=0x%0X", pkt->flags);
 +    if (pkt->side_data_elems) {
 +        int i, j;
 +        av_strlcatf(buf, sizeof(buf), ", S=%d", pkt->side_data_elems);
 +
 +        for (i=0; i<pkt->side_data_elems; i++) {
 +            uint32_t side_data_crc = 0;
 +            if (HAVE_BIGENDIAN && AV_PKT_DATA_PALETTE == pkt->side_data[i].type) {
 +                for (j=0; j<pkt->side_data[i].size; j++) {
 +                    side_data_crc = av_adler32_update(side_data_crc,
 +                                                      pkt->side_data[i].data + (j^3),
 +                                                      1);
 +                }
 +            } else {
 +                side_data_crc = av_adler32_update(0,
 +                                                  pkt->side_data[i].data,
 +                                                  pkt->side_data[i].size);
 +            }
 +            av_strlcatf(buf, sizeof(buf), ", %8d, 0x%08x", pkt->side_data[i].size, side_data_crc);
 +        }
 +    }
 +    av_strlcatf(buf, sizeof(buf), "\n");
      avio_write(s->pb, buf, strlen(buf));
      return 0;
  }
@@@ -291,9 -260,10 +293,11 @@@ static void gxf_read_index(AVFormatCont
          avio_skip(pb, pkt_len);
          return;
      }
 +    st = s->streams[0];
      if (map_cnt > 1000) {
-         av_log(s, AV_LOG_ERROR, "too many index entries %u (%x)\n", map_cnt, map_cnt);
+         av_log(s, AV_LOG_ERROR,
+                "too many index entries %"PRIu32" (%"PRIx32")\n",
+                map_cnt, map_cnt);
          map_cnt = 1000;
      }
      if (pkt_len < 4 * map_cnt) {
@@@ -148,9 -150,10 +150,10 @@@ static int hnm_read_packet(AVFormatCont
      chunk_id = avio_rl16(pb);
      avio_skip(pb, 2);
  
 -    if (chunk_size > hnm->superchunk_remaining) {
 +    if (chunk_size > hnm->superchunk_remaining || !chunk_size) {
-         av_log(s, AV_LOG_ERROR, "invalid chunk size: %u, offset: %u\n",
-                chunk_size, (int) avio_tell(pb));
+         av_log(s, AV_LOG_ERROR,
+                "invalid chunk size: %"PRIu32", offset: %"PRId64"\n",
+                chunk_size, avio_tell(pb));
          avio_skip(pb, hnm->superchunk_remaining - 8);
          hnm->superchunk_remaining = 0;
      }
@@@ -28,7 -29,8 +28,9 @@@
   * http://wiki.multimedia.cx/index.php?title=IFF
   */
  
+ #include <inttypes.h>
 +#include "libavutil/avassert.h"
  #include "libavutil/channel_layout.h"
  #include "libavutil/intreadwrite.h"
  #include "libavutil/dict.h"
@@@ -243,15 -167,9 +245,15 @@@ static int iff_read_header(AVFormatCont
              }
              break;
  
 +        case ID_CAMG:
 +            if (data_size < 4)
 +                return AVERROR_INVALIDDATA;
 +            screenmode                = avio_rb32(pb);
 +            break;
 +
          case ID_CMAP:
              if (data_size < 3 || data_size > 768 || data_size % 3) {
-                  av_log(s, AV_LOG_ERROR, "Invalid CMAP chunk size %d\n",
+                  av_log(s, AV_LOG_ERROR, "Invalid CMAP chunk size %"PRIu32"\n",
                          data_size);
                   return AVERROR_INVALIDDATA;
              }
Simple merge
Simple merge
@@@ -1649,7 -1455,7 +1650,7 @@@ int ff_mov_read_stsd_entries(MOVContex
  
          id = mov_codec_id(st, format);
  
-         av_dlog(c->fc, "size=%"PRId64" 4CC= %c%c%c%c codec_type=%d\n", size,
 -        av_dlog(c->fc, "size=%"PRIu32" 4CC= %"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8" codec_type=%d\n", size,
++        av_dlog(c->fc, "size=%"PRId64" 4CC= %"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8" codec_type=%d\n", size,
                  (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
                  (format >> 24) & 0xff, st->codec->codec_type);
  
Simple merge
   * Only tracks with associated descriptors will be decoded. "Highly Desirable" SMPTE 377M D.1
   */
  
- #include <stdint.h>
+ #include <inttypes.h>
  
  #include "libavutil/aes.h"
 +#include "libavutil/avassert.h"
  #include "libavutil/mathematics.h"
  #include "libavcodec/bytestream.h"
 +#include "libavutil/intreadwrite.h"
 +#include "libavutil/timecode.h"
  #include "avformat.h"
  #include "internal.h"
  #include "mxf.h"
@@@ -554,9 -539,10 +556,10 @@@ static int mxf_read_partition_pack(voi
      }
  
      if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
-         av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
+         av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %"PRId32" - guessing ",
+                partition->kag_size);
  
 -        if (mxf->op == OPSonyOpt)
 +        if (mxf->op == OPSONYOpt)
              partition->kag_size = 512;
          else
              partition->kag_size = 1;
Simple merge
@@@ -19,7 -19,8 +19,9 @@@
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
+ #include <inttypes.h>
 +#include "libavutil/avassert.h"
  #include "libavutil/avstring.h"
  #include "libavutil/channel_layout.h"
  #include "libavutil/internal.h"
@@@ -279,19 -271,9 +281,19 @@@ static int rm_read_audio_stream_info(AV
          case DEINT_ID_VBRF:
              break;
          default:
-             av_log(s, AV_LOG_ERROR, "Unknown interleaver %X\n", ast->deint_id);
 -            av_log(NULL, 0 ,"Unknown interleaver %"PRIX32"\n", ast->deint_id);
++            av_log(s, AV_LOG_ERROR ,"Unknown interleaver %"PRIX32"\n", ast->deint_id);
              return AVERROR_INVALIDDATA;
          }
 +        if (ast->deint_id == DEINT_ID_INT4 ||
 +            ast->deint_id == DEINT_ID_GENR ||
 +            ast->deint_id == DEINT_ID_SIPR) {
 +            if (st->codec->block_align <= 0 ||
 +                ast->audio_framesize * sub_packet_h > (unsigned)INT_MAX ||
 +                ast->audio_framesize * sub_packet_h < st->codec->block_align)
 +                return AVERROR_INVALIDDATA;
 +            if (av_new_packet(&ast->pkt, ast->audio_framesize * sub_packet_h) < 0)
 +                return AVERROR(ENOMEM);
 +        }
  
          if (read_all) {
              avio_r8(pb);
@@@ -221,8 -222,11 +221,9 @@@ static int rpl_read_header(AVFormatCont
                  }
                  break;
          }
 -        if (ast->codec->codec_id == AV_CODEC_ID_NONE) {
 -            av_log(s, AV_LOG_WARNING,
 -                   "RPL audio format %"PRId32" not supported yet!\n",
 -                   audio_format);
 -        }
 +        if (ast->codec->codec_id == AV_CODEC_ID_NONE)
-             avpriv_request_sample(s, "Audio format %i", audio_format);
++            avpriv_request_sample(s, "Audio format %"PRId32,
++                                  audio_format);
          avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
      } else {
          for (i = 0; i < 3; i++)
@@@ -142,16 -141,11 +144,16 @@@ static int smacker_read_header(AVFormat
      smk->pad = avio_rl32(pb);
      /* setup data */
      if(smk->frames > 0xFFFFFF) {
-         av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
+         av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames);
 -        return -1;
 +        return AVERROR_INVALIDDATA;
      }
 -    smk->frm_size = av_malloc(smk->frames * 4);
 +    smk->frm_size = av_malloc_array(smk->frames, sizeof(*smk->frm_size));
      smk->frm_flags = av_malloc(smk->frames);
 +    if (!smk->frm_size || !smk->frm_flags) {
 +        av_freep(&smk->frm_size);
 +        av_freep(&smk->frm_flags);
 +        return AVERROR(ENOMEM);
 +    }
  
      smk->is_ver4 = (smk->magic != MKTAG('S', 'M', 'K', '2'));
  
  
  
      /* load trees to extradata, they will be unpacked by decoder */
 -    st->codec->extradata = av_mallocz(smk->treesize + 16 +
 -                                      FF_INPUT_BUFFER_PADDING_SIZE);
 -    st->codec->extradata_size = smk->treesize + 16;
 -    if(!st->codec->extradata){
 +    if(ff_alloc_extradata(st->codec, smk->treesize + 16)){
-         av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
+         av_log(s, AV_LOG_ERROR,
+                "Cannot allocate %"PRIu32" bytes of extradata\n",
+                smk->treesize + 16);
 -        av_free(smk->frm_size);
 -        av_free(smk->frm_flags);
 -        return -1;
 +        av_freep(&smk->frm_size);
 +        av_freep(&smk->frm_flags);
 +        return AVERROR(ENOMEM);
      }
      ret = avio_read(pb, st->codec->extradata + 16, st->codec->extradata_size - 16);
      if(ret != st->codec->extradata_size - 16){
Simple merge
Simple merge
Simple merge
@@@ -213,13 -222,13 +213,13 @@@ static int xmv_read_header(AVFormatCont
  
          /* TODO: ADPCM'd 5.1 sound is encoded in three separate streams.
           *       Those need to be interleaved to a proper 5.1 stream. */
 -        if (track->flags & XMV_AUDIO_ADPCM51)
 +        if (packet->flags & XMV_AUDIO_ADPCM51)
              av_log(s, AV_LOG_WARNING, "Unsupported 5.1 ADPCM audio stream "
 -                                      "(0x%04X)\n", track->flags);
 +                                      "(0x%04X)\n", packet->flags);
  
 -        if (!track->channels || !track->sample_rate ||
 -             track->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
 +        if (!packet->channels || !packet->sample_rate ||
 +             packet->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
-             av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
+             av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n",
                     audio_track);
              ret = AVERROR_INVALIDDATA;
              goto fail;