annotate mmf.c @ 5963:12bdd63f5259 libavformat

Implement librtmp seek support. Implement flv_read_seek(), add a missing check on stream_index and fix timestamp rounding in rtmp_read_seek(). Also add the flv_read_seek2() function, which is not enabled but is useful as reference. To actually implement flv_read_seek2() correctly, there would need to be some corresponding av_url_read_fseek2() function to propagate the timestamps down to the ByteIOContext and URLContext. Patch by Howard Chu <hyc <at> highlandsun.com>. See the thread: Subject: [FFmpeg-devel] RTMP seek support Date: 2010-03-28 23:35:02 GMT
author stefano
date Sun, 18 Apr 2010 19:09:25 +0000
parents 536e5527c1e0
children 4aaed59641ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
1 /*
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
2 * Yamaha SMAF format
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
3 * Copyright (c) 2005 Vidar Madsen
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
15 * Lesser General Public License for more details.
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
16 *
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1172
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 885
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
20 */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
21 #include "avformat.h"
2545
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2274
diff changeset
22 #include "raw.h"
1172
6a5e58d2114b move common stuff from avienc.c and wav.c to new file riff.c
mru
parents: 1169
diff changeset
23 #include "riff.h"
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
24
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
25 typedef struct {
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
26 int64_t atrpos, atsqpos, awapos;
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
27 int64_t data_size;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
28 } MMFContext;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
29
3769
93d4898d9b6e Mark several libavformat arrays const
reimar
parents: 3763
diff changeset
30 static const int mmf_rates[] = { 4000, 8000, 11025, 22050, 44100 };
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
31
3560
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
32 static int mmf_rate(int code)
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
33 {
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
34 if((code < 0) || (code > 4))
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
35 return -1;
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
36 return mmf_rates[code];
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
37 }
507108c26477 Move a function and an #ifdef CONFIG_MUXERS so that functions used only for
diego
parents: 3436
diff changeset
38
4206
c3102b189cb6 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 3973
diff changeset
39 #if CONFIG_MMF_MUXER
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
40 static int mmf_rate_code(int rate)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
41 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
42 int i;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
43 for(i = 0; i < 5; i++)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
44 if(mmf_rates[i] == rate)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
45 return i;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
46 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
47 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
48
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
49 /* Copy of end_tag() from avienc.c, but for big-endian chunk size */
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
50 static void end_tag_be(ByteIOContext *pb, int64_t start)
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
51 {
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
52 int64_t pos;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
53
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
54 pos = url_ftell(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
55 url_fseek(pb, start - 4, SEEK_SET);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
56 put_be32(pb, (uint32_t)(pos - start));
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
57 url_fseek(pb, pos, SEEK_SET);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
58 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
59
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
60 static int mmf_write_header(AVFormatContext *s)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
61 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
62 MMFContext *mmf = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
63 ByteIOContext *pb = s->pb;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
64 int64_t pos;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
65 int rate;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
66
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
67 rate = mmf_rate_code(s->streams[0]->codec->sample_rate);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
68 if(rate < 0) {
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
69 av_log(s, AV_LOG_ERROR, "Unsupported sample rate %d\n", s->streams[0]->codec->sample_rate);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
70 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
71 }
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
72
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
73 put_tag(pb, "MMMD");
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
74 put_be32(pb, 0);
5058
33a244b7ca65 Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents: 4465
diff changeset
75 pos = ff_start_tag(pb, "CNTI");
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
76 put_byte(pb, 0); /* class */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
77 put_byte(pb, 0); /* type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
78 put_byte(pb, 0); /* code type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
79 put_byte(pb, 0); /* status */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
80 put_byte(pb, 0); /* counts */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
81 put_tag(pb, "VN:libavcodec,"); /* metadata ("ST:songtitle,VN:version,...") */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
82 end_tag_be(pb, pos);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
83
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
84 put_buffer(pb, "ATR\x00", 4);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
85 put_be32(pb, 0);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
86 mmf->atrpos = url_ftell(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
87 put_byte(pb, 0); /* format type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
88 put_byte(pb, 0); /* sequence type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
89 put_byte(pb, (0 << 7) | (1 << 4) | rate); /* (channel << 7) | (format << 4) | rate */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
90 put_byte(pb, 0); /* wave base bit */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
91 put_byte(pb, 2); /* time base d */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
92 put_byte(pb, 2); /* time base g */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
93
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
94 put_tag(pb, "Atsq");
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
95 put_be32(pb, 16);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
96 mmf->atsqpos = url_ftell(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
97 /* Will be filled on close */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
98 put_buffer(pb, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
99
5058
33a244b7ca65 Add ff_ prefixes to exported symbols in libavformat/riff.h.
diego
parents: 4465
diff changeset
100 mmf->awapos = ff_start_tag(pb, "Awa\x01");
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
101
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
102 av_set_pts_info(s->streams[0], 64, 1, s->streams[0]->codec->sample_rate);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
103
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
104 put_flush_packet(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
105
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
106 return 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
107 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
108
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
109 static int mmf_write_packet(AVFormatContext *s, AVPacket *pkt)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
110 {
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
111 ByteIOContext *pb = s->pb;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
112 put_buffer(pb, pkt->data, pkt->size);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
113 return 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
114 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
115
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
116 /* Write a variable-length symbol */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
117 static void put_varlength(ByteIOContext *pb, int val)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
118 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
119 if(val < 128)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
120 put_byte(pb, val);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
121 else {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
122 val -= 128;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
123 put_byte(pb, 0x80 | val >> 7);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
124 put_byte(pb, 0x7f & val);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
125 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
126 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
127
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
128 static int mmf_write_trailer(AVFormatContext *s)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
129 {
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
130 ByteIOContext *pb = s->pb;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
131 MMFContext *mmf = s->priv_data;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
132 int64_t pos, size;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
133 int gatetime;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
134
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
135 if (!url_is_streamed(s->pb)) {
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
136 /* Fill in length fields */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
137 end_tag_be(pb, mmf->awapos);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
138 end_tag_be(pb, mmf->atrpos);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
139 end_tag_be(pb, 8);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
140
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
141 pos = url_ftell(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
142 size = pos - mmf->awapos;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
143
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
144 /* Fill Atsq chunk */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
145 url_fseek(pb, mmf->atsqpos, SEEK_SET);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
146
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
147 /* "play wav" */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
148 put_byte(pb, 0); /* start time */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
149 put_byte(pb, 1); /* (channel << 6) | wavenum */
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
150 gatetime = size * 500 / s->streams[0]->codec->sample_rate;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
151 put_varlength(pb, gatetime); /* duration */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
152
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
153 /* "nop" */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
154 put_varlength(pb, gatetime); /* start time */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
155 put_buffer(pb, "\xff\x00", 2); /* nop */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
156
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
157 /* "end of sequence" */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
158 put_buffer(pb, "\x00\x00\x00\x00", 4);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
159
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
160 url_fseek(pb, pos, SEEK_SET);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
161
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
162 put_flush_packet(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
163 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
164 return 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
165 }
3871
e6aeb2733e34 Replace generic CONFIG_MUXERS preprocessor conditionals by more specific
diego
parents: 3769
diff changeset
166 #endif /* CONFIG_MMF_MUXER */
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
167
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
168 static int mmf_probe(AVProbeData *p)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
169 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
170 /* check file header */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
171 if (p->buf[0] == 'M' && p->buf[1] == 'M' &&
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
172 p->buf[2] == 'M' && p->buf[3] == 'D' &&
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
173 p->buf[8] == 'C' && p->buf[9] == 'N' &&
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
174 p->buf[10] == 'T' && p->buf[11] == 'I')
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
175 return AVPROBE_SCORE_MAX;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
176 else
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
177 return 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
178 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
179
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
180 /* mmf input */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
181 static int mmf_read_header(AVFormatContext *s,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
182 AVFormatParameters *ap)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
183 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
184 MMFContext *mmf = s->priv_data;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
185 unsigned int tag;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
186 ByteIOContext *pb = s->pb;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
187 AVStream *st;
3973
549a09cf23fe Remove offset_t typedef and use int64_t directly instead.
diego
parents: 3908
diff changeset
188 int64_t file_size, size;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
189 int rate, params;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
190
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
191 tag = get_le32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
192 if (tag != MKTAG('M', 'M', 'M', 'D'))
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
193 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
194 file_size = get_be32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
195
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
196 /* Skip some unused chunks that may or may not be present */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
197 for(;; url_fseek(pb, size, SEEK_CUR)) {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
198 tag = get_le32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
199 size = get_be32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
200 if(tag == MKTAG('C','N','T','I')) continue;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
201 if(tag == MKTAG('O','P','D','A')) continue;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
202 break;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
203 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
204
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
205 /* Tag = "ATRx", where "x" = track number */
1065
fab79efcd476 report to user if mmf with midi found (and not supported)
alex
parents: 902
diff changeset
206 if ((tag & 0xffffff) == MKTAG('M', 'T', 'R', 0)) {
fab79efcd476 report to user if mmf with midi found (and not supported)
alex
parents: 902
diff changeset
207 av_log(s, AV_LOG_ERROR, "MIDI like format found, unsupported\n");
fab79efcd476 report to user if mmf with midi found (and not supported)
alex
parents: 902
diff changeset
208 return -1;
fab79efcd476 report to user if mmf with midi found (and not supported)
alex
parents: 902
diff changeset
209 }
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
210 if ((tag & 0xffffff) != MKTAG('A', 'T', 'R', 0)) {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
211 av_log(s, AV_LOG_ERROR, "Unsupported SMAF chunk %08x\n", tag);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
212 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
213 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
214
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
215 get_byte(pb); /* format type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
216 get_byte(pb); /* sequence type */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
217 params = get_byte(pb); /* (channel << 7) | (format << 4) | rate */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
218 rate = mmf_rate(params & 0x0f);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
219 if(rate < 0) {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
220 av_log(s, AV_LOG_ERROR, "Invalid sample rate\n");
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
221 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
222 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
223 get_byte(pb); /* wave base bit */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
224 get_byte(pb); /* time base d */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
225 get_byte(pb); /* time base g */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
226
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
227 /* Skip some unused chunks that may or may not be present */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
228 for(;; url_fseek(pb, size, SEEK_CUR)) {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
229 tag = get_le32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
230 size = get_be32(pb);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
231 if(tag == MKTAG('A','t','s','q')) continue;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
232 if(tag == MKTAG('A','s','p','I')) continue;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
233 break;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
234 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
235
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
236 /* Make sure it's followed by an Awa chunk, aka wave data */
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
237 if ((tag & 0xffffff) != MKTAG('A', 'w', 'a', 0)) {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
238 av_log(s, AV_LOG_ERROR, "Unexpected SMAF chunk %08x\n", tag);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
239 return -1;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
240 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
241 mmf->data_size = size;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
242
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
243 st = av_new_stream(s, 0);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
244 if (!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2001
diff changeset
245 return AVERROR(ENOMEM);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
246
5910
536e5527c1e0 Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents: 5058
diff changeset
247 st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
248 st->codec->codec_id = CODEC_ID_ADPCM_YAMAHA;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
249 st->codec->sample_rate = rate;
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
250 st->codec->channels = 1;
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3871
diff changeset
251 st->codec->bits_per_coded_sample = 4;
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3871
diff changeset
252 st->codec->bit_rate = st->codec->sample_rate * st->codec->bits_per_coded_sample;
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
253
820
feca73904e67 changing AVCodecContext codec -> *codec in AVStream so additions to AVCodecContext dont randomize AVStream and break binary compatibility
michael
parents: 818
diff changeset
254 av_set_pts_info(st, 64, 1, st->codec->sample_rate);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
255
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
256 return 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
257 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
258
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
259 #define MAX_SIZE 4096
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
260
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
261 static int mmf_read_packet(AVFormatContext *s,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
262 AVPacket *pkt)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
263 {
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
264 MMFContext *mmf = s->priv_data;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
265 AVStream *st;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
266 int ret, size;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
267
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
268 if (url_feof(s->pb))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
269 return AVERROR(EIO);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
270 st = s->streams[0];
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
271
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
272 size = MAX_SIZE;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
273 if(size > mmf->data_size)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
274 size = mmf->data_size;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
275
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
276 if(!size)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
277 return AVERROR(EIO);
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 858
diff changeset
278
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
279 if (av_new_packet(pkt, size))
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
280 return AVERROR(EIO);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
281 pkt->stream_index = 0;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
282
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2545
diff changeset
283 ret = get_buffer(s->pb, pkt->data, pkt->size);
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
284 if (ret < 0)
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
285 av_free_packet(pkt);
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
286
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
287 mmf->data_size -= ret;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
288
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
289 pkt->size = ret;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
290 return ret;
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
291 }
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
292
4206
c3102b189cb6 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 3973
diff changeset
293 #if CONFIG_MMF_DEMUXER
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
294 AVInputFormat mmf_demuxer = {
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
295 "mmf",
4465
042e9a2fdda2 Use more descriptive format long_names.
diego
parents: 4206
diff changeset
296 NULL_IF_CONFIG_SMALL("Yamaha SMAF"),
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
297 sizeof(MMFContext),
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
298 mmf_probe,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
299 mmf_read_header,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
300 mmf_read_packet,
3763
457a89a670cf Remove useless empty close functions in mmf and mm demuxers.
reimar
parents: 3560
diff changeset
301 NULL,
3436
ec4945b71d48 Remove wrappers of pcm_read_seek().
ramiro
parents: 3424
diff changeset
302 pcm_read_seek,
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
303 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
304 #endif
4206
c3102b189cb6 Change semantic of CONFIG_*, HAVE_* and ARCH_*.
aurel
parents: 3973
diff changeset
305 #if CONFIG_MMF_MUXER
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
306 AVOutputFormat mmf_muxer = {
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
307 "mmf",
4465
042e9a2fdda2 Use more descriptive format long_names.
diego
parents: 4206
diff changeset
308 NULL_IF_CONFIG_SMALL("Yamaha SMAF"),
818
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
309 "application/vnd.smaf",
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
310 "mmf",
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
311 sizeof(MMFContext),
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
312 CODEC_ID_ADPCM_YAMAHA,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
313 CODEC_ID_NONE,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
314 mmf_write_header,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
315 mmf_write_packet,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
316 mmf_write_trailer,
b1d7ee1c792d Yamaha SMAF file format support patch by (Vidar Madsen: vidarino, gmail com)
michael
parents:
diff changeset
317 };
1169
d18cc9a1fd02 allow individual selection of muxers and demuxers
mru
parents: 1167
diff changeset
318 #endif