Mercurial > libavformat.hg
annotate flacenc_header.c @ 6099:ed24da0b0cee libavformat
bgr/rgb444 for nut
author | michael |
---|---|
date | Sun, 06 Jun 2010 11:43:53 +0000 |
parents | e3fb53259d86 |
children |
rev | line source |
---|---|
4581
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
1 /* |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
2 * raw FLAC muxer |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
3 * Copyright (C) 2009 Justin Ruggles |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
4 * |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
5 * This file is part of FFmpeg. |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
6 * |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
8 * modify it under the terms of the GNU Lesser General Public |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
9 * License as published by the Free Software Foundation; either |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
11 * |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
15 * Lesser General Public License for more details. |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
16 * |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
20 */ |
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
21 |
5868
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
22 #include "libavcodec/flac.h" |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
23 #include "libavcodec/bytestream.h" |
4581
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
24 #include "avformat.h" |
5873
e3fb53259d86
Put ff_flac_write_header() in a separate C file to allow it to be shared without
jbr
parents:
5868
diff
changeset
|
25 #include "flacenc.h" |
4581
c52d40f0a955
Share the function to write a raw FLAC header and use it in the Matroska
jbr
parents:
diff
changeset
|
26 |
5873
e3fb53259d86
Put ff_flac_write_header() in a separate C file to allow it to be shared without
jbr
parents:
5868
diff
changeset
|
27 int ff_flac_write_header(ByteIOContext *pb, AVCodecContext *codec, |
e3fb53259d86
Put ff_flac_write_header() in a separate C file to allow it to be shared without
jbr
parents:
5868
diff
changeset
|
28 int last_block) |
5868
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
29 { |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
30 uint8_t header[8] = { |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
31 0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22 |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
32 }; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
33 uint8_t *streaminfo; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
34 enum FLACExtradataFormat format; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
35 |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
36 header[4] = last_block ? 0x80 : 0x00; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
37 if (!ff_flac_is_extradata_valid(codec, &format, &streaminfo)) |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
38 return -1; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
39 |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
40 /* write "fLaC" stream marker and first metadata block header if needed */ |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
41 if (format == FLAC_EXTRADATA_FORMAT_STREAMINFO) { |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
42 put_buffer(pb, header, 8); |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
43 } |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
44 |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
45 /* write STREAMINFO or full header */ |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
46 put_buffer(pb, codec->extradata, codec->extradata_size); |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
47 |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
48 return 0; |
92daebc423f4
Move ff_flac_write_header() to flacenc.h, which removes the Matroska muxer's
jbr
parents:
5857
diff
changeset
|
49 } |