]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/cafdec.c
dump: split audio and video probing on multiple lines
[ffmpeg] / libavformat / cafdec.c
index 15a1e2207cf5d6d10efbca98d4ee32250d481021..4489eb26b2c982331664fa38a7a598a2f168c6d0 100644 (file)
  * Core Audio Format demuxer
  */
 
+#include <inttypes.h>
+
 #include "avformat.h"
 #include "internal.h"
-#include "riff.h"
 #include "isom.h"
+#include "mov_chan.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
 #include "libavutil/dict.h"
@@ -44,7 +46,7 @@ typedef struct {
 
     int64_t data_start;             ///< data start position, in bytes
     int64_t data_size;              ///< raw data size, in bytes
-} CaffContext;
+} CafContext;
 
 static int probe(AVProbeData *p)
 {
@@ -57,7 +59,7 @@ static int probe(AVProbeData *p)
 static int read_desc_chunk(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
-    CaffContext *caf  = s->priv_data;
+    CafContext *caf = s->priv_data;
     AVStream *st;
     int flags;
 
@@ -102,28 +104,27 @@ static int read_kuki_chunk(AVFormatContext *s, int64_t size)
     if (size < 0 || size > INT_MAX - FF_INPUT_BUFFER_PADDING_SIZE)
         return -1;
 
-    if (st->codec->codec_id == CODEC_ID_AAC) {
+    if (st->codec->codec_id == AV_CODEC_ID_AAC) {
         /* The magic cookie format for AAC is an mp4 esds atom.
            The lavc AAC decoder requires the data from the codec specific
            description as extradata input. */
         int strt, skip;
-        MOVAtom atom;
 
         strt = avio_tell(pb);
-        ff_mov_read_esds(s, pb, atom);
+        ff_mov_read_esds(s, pb);
         skip = size - (avio_tell(pb) - strt);
         if (skip < 0 || !st->codec->extradata ||
-            st->codec->codec_id != CODEC_ID_AAC) {
+            st->codec->codec_id != AV_CODEC_ID_AAC) {
             av_log(s, AV_LOG_ERROR, "invalid AAC magic cookie\n");
             return AVERROR_INVALIDDATA;
         }
         avio_skip(pb, skip);
-    } else if (st->codec->codec_id == CODEC_ID_ALAC) {
+    } else if (st->codec->codec_id == AV_CODEC_ID_ALAC) {
 #define ALAC_PREAMBLE 12
 #define ALAC_HEADER   36
 #define ALAC_NEW_KUKI 24
         uint8_t preamble[12];
-        if (size < ALAC_NEW_KUKI || size > ALAC_PREAMBLE + ALAC_HEADER) {
+        if (size < ALAC_NEW_KUKI) {
             av_log(s, AV_LOG_ERROR, "invalid ALAC magic cookie\n");
             avio_skip(pb, size);
             return AVERROR_INVALIDDATA;
@@ -171,7 +172,7 @@ static int read_pakt_chunk(AVFormatContext *s, int64_t size)
 {
     AVIOContext *pb = s->pb;
     AVStream *st      = s->streams[0];
-    CaffContext *caf  = s->priv_data;
+    CafContext *caf   = s->priv_data;
     int64_t pos = 0, ccount, num_packets;
     int i;
 
@@ -220,7 +221,7 @@ static void read_info_chunk(AVFormatContext *s, int64_t size)
 static int read_header(AVFormatContext *s)
 {
     AVIOContext *pb = s->pb;
-    CaffContext *caf  = s->priv_data;
+    CafContext *caf = s->priv_data;
     AVStream *st;
     uint32_t tag = 0;
     int found_data, ret;
@@ -266,6 +267,11 @@ static int read_header(AVFormatContext *s)
             found_data = 1;
             break;
 
+        case MKBETAG('c','h','a','n'):
+            if ((ret = ff_mov_read_chan(s, s->pb, st, size)) < 0)
+                return ret;
+            break;
+
         /* magic cookie chunk */
         case MKBETAG('k','u','k','i'):
             if (read_kuki_chunk(s, size))
@@ -284,7 +290,8 @@ static int read_header(AVFormatContext *s)
 
         default:
 #define _(x) ((x) >= ' ' ? (x) : ' ')
-            av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c)\n",
+            av_log(s, AV_LOG_WARNING,
+                   "skipping CAF chunk: %08"PRIX32" (%"PRIu32"%"PRIu32"%"PRIu32"%"PRIu32")\n",
                 tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF));
 #undef _
         case MKBETAG('f','r','e','e'):
@@ -326,7 +333,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
 {
     AVIOContext *pb = s->pb;
     AVStream *st      = s->streams[0];
-    CaffContext *caf  = s->priv_data;
+    CafContext *caf   = s->priv_data;
     int res, pkt_size = 0, pkt_frames = 0;
     int64_t left      = CAF_MAX_PKT_SIZE;
 
@@ -380,7 +387,7 @@ static int read_seek(AVFormatContext *s, int stream_index,
                      int64_t timestamp, int flags)
 {
     AVStream *st = s->streams[0];
-    CaffContext *caf = s->priv_data;
+    CafContext *caf = s->priv_data;
     int64_t pos, packet_cnt, frame_cnt;
 
     timestamp = FFMAX(timestamp, 0);
@@ -411,8 +418,8 @@ static int read_seek(AVFormatContext *s, int stream_index,
 
 AVInputFormat ff_caf_demuxer = {
     .name           = "caf",
-    .long_name      = NULL_IF_CONFIG_SMALL("Apple Core Audio Format"),
-    .priv_data_size = sizeof(CaffContext),
+    .long_name      = NULL_IF_CONFIG_SMALL("Apple CAF (Core Audio Format)"),
+    .priv_data_size = sizeof(CafContext),
     .read_probe     = probe,
     .read_header    = read_header,
     .read_packet    = read_packet,