FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
rawdec.c
Go to the documentation of this file.
1 /*
2  * RAW demuxers
3  * Copyright (c) 2001 Fabrice Bellard
4  * Copyright (c) 2005 Alex Beregszaszi
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #include "avformat.h"
24 #include "internal.h"
25 #include "avio_internal.h"
26 #include "rawdec.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/parseutils.h"
29 #include "libavutil/pixdesc.h"
30 #include "libavutil/avassert.h"
31 
32 #define RAW_PACKET_SIZE 1024
33 
35 {
36  int ret, size;
37 
38  size = RAW_PACKET_SIZE;
39 
40  if (av_new_packet(pkt, size) < 0)
41  return AVERROR(ENOMEM);
42 
43  pkt->pos= avio_tell(s->pb);
44  pkt->stream_index = 0;
45  ret = ffio_read_partial(s->pb, pkt->data, size);
46  if (ret < 0) {
47  av_free_packet(pkt);
48  return ret;
49  }
50  av_shrink_packet(pkt, ret);
51  return ret;
52 }
53 
55 {
56  AVStream *st = avformat_new_stream(s, NULL);
57  if (!st)
58  return AVERROR(ENOMEM);
62  st->start_time = 0;
63  /* the parameters will be extracted from the compressed bitstream */
64 
65  return 0;
66 }
67 
68 /* MPEG-1/H.263 input */
70 {
71  AVStream *st;
73  int ret = 0;
74 
75 
76  st = avformat_new_stream(s, NULL);
77  if (!st) {
78  ret = AVERROR(ENOMEM);
79  goto fail;
80  }
81 
85 
86  st->codec->time_base = av_inv_q(s1->framerate);
87  avpriv_set_pts_info(st, 64, 1, 1200000);
88 
89 fail:
90  return ret;
91 }
92 
94 {
95  AVStream *st = avformat_new_stream(s, NULL);
96  if (!st)
97  return AVERROR(ENOMEM);
100  st->start_time = 0;
101  return 0;
102 }
103 
104 /* Note: Do not forget to add new entries to the Makefile as well. */
105 
106 #define OFFSET(x) offsetof(FFRawVideoDemuxerContext, x)
107 #define DEC AV_OPT_FLAG_DECODING_PARAM
109  { "framerate", "", OFFSET(framerate), AV_OPT_TYPE_VIDEO_RATE, {.str = "25"}, 0, 0, DEC},
110  { NULL },
111 };
112 
113 #if CONFIG_DATA_DEMUXER
114 AVInputFormat ff_data_demuxer = {
115  .name = "data",
116  .long_name = NULL_IF_CONFIG_SMALL("raw data"),
117  .read_header = ff_raw_data_read_header,
118  .read_packet = ff_raw_read_partial_packet,
119  .raw_codec_id = AV_CODEC_ID_NONE,
120 };
121 #endif
122 
123 #if CONFIG_LATM_DEMUXER
124 AVInputFormat ff_latm_demuxer = {
125  .name = "latm",
126  .long_name = NULL_IF_CONFIG_SMALL("raw LOAS/LATM"),
127  .read_header = ff_raw_audio_read_header,
128  .read_packet = ff_raw_read_partial_packet,
129  .flags = AVFMT_GENERIC_INDEX,
130  .extensions = "latm",
131  .raw_codec_id = AV_CODEC_ID_AAC_LATM,
132 };
133 #endif
134 
135 #if CONFIG_MJPEG_DEMUXER
136 FF_DEF_RAWVIDEO_DEMUXER(mjpeg, "raw MJPEG video", NULL, "mjpg,mjpeg,mpo", AV_CODEC_ID_MJPEG)
137 #endif
138 
139 #if CONFIG_MLP_DEMUXER
140 AVInputFormat ff_mlp_demuxer = {
141  .name = "mlp",
142  .long_name = NULL_IF_CONFIG_SMALL("raw MLP"),
143  .read_header = ff_raw_audio_read_header,
144  .read_packet = ff_raw_read_partial_packet,
145  .flags = AVFMT_GENERIC_INDEX,
146  .extensions = "mlp",
147  .raw_codec_id = AV_CODEC_ID_MLP,
148 };
149 #endif
150 
151 #if CONFIG_TRUEHD_DEMUXER
152 AVInputFormat ff_truehd_demuxer = {
153  .name = "truehd",
154  .long_name = NULL_IF_CONFIG_SMALL("raw TrueHD"),
155  .read_header = ff_raw_audio_read_header,
156  .read_packet = ff_raw_read_partial_packet,
157  .flags = AVFMT_GENERIC_INDEX,
158  .extensions = "thd",
159  .raw_codec_id = AV_CODEC_ID_TRUEHD,
160 };
161 #endif
162 
163 #if CONFIG_SHORTEN_DEMUXER
164 AVInputFormat ff_shorten_demuxer = {
165  .name = "shn",
166  .long_name = NULL_IF_CONFIG_SMALL("raw Shorten"),
167  .read_header = ff_raw_audio_read_header,
168  .read_packet = ff_raw_read_partial_packet,
170  .extensions = "shn",
171  .raw_codec_id = AV_CODEC_ID_SHORTEN,
172 };
173 #endif
174 
175 #if CONFIG_VC1_DEMUXER
176 FF_DEF_RAWVIDEO_DEMUXER(vc1, "raw VC-1", NULL, "vc1", AV_CODEC_ID_VC1)
177 #endif