1 /*
2 * Image format
3 * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
4 * Copyright (c) 2004 Michael Niedermayer
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
34
36 const AVClass *
class;
/**< Class for private options. */
39 int split_planes;
/**< use independent file for each Y, U, V plane */
48
50 {
54
56
57 /* find format */
60 else
62
66 const char *str = strrchr(img->
path,
'.');
70 && desc
73 }
74
75 return 0;
76 }
77
79 {
82 char filename[1024];
85 int i;
86 int nb_renames = 0;
87
92 time_t now0;
93 struct tm *tm, tmpbuf;
94 time(&now0);
96 if (!strftime(filename,
sizeof(filename), img->
path, tm)) {
99 }
103 "Could not get frame filename number %d from pattern '%s' (either set updatefirst or use a pattern like %%03d within the filename pattern)\n",
106 }
107 for (i = 0; i < 4; i++) {
113 }
114
116 break;
117 filename[strlen(filename) - 1] = "UVAx"[i];
118 }
120 nb_renames = i + 1;
121 } else {
123 }
124
129 ysize *= 2;
130 usize *= 2;
131 }
140 }
141 }
else if (img->
muxer) {
142 int ret;
146
148
150 if (ret < 0)
151 return ret;
153 if (!st) {
156 }
158
168 return ret;
169 }
172 } else {
174 }
178 for (i = 0; i < nb_renames; i++) {
180 if (ret < 0)
181 return ret;
182 }
183 }
184
186 return 0;
187 }
188
190 {
191 int i;
194 return 1;
195
196 // Anything really can be stored in img2
198 }
199
200 #define OFFSET(x) offsetof(VideoMuxData, x)
201 #define ENC AV_OPT_FLAG_ENCODING_PARAM
205 {
"start_number",
"set first number in the sequence",
OFFSET(img_number),
AV_OPT_TYPE_INT, { .i64 = 1 }, 0, INT_MAX,
ENC },
207 {
"atomic_writing",
"write files atomically (using temporary files and renames)",
OFFSET(use_rename),
AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1,
ENC },
209 };
210
211 #if CONFIG_IMAGE2_MUXER
212 static const AVClass img2mux_class = {
217 };
218
222 .extensions = "bmp,dpx,jls,jpeg,jpg,ljpg,pam,pbm,pcx,pgm,pgmyuv,png,"
223 "ppm,sgi,tga,tif,tiff,jp2,j2c,j2k,xwd,sun,ras,rs,im1,im8,im24,"
224 "sunras,xbm,xface,pix,y",
231 .priv_class = &img2mux_class,
232 };
233 #endif
234 #if CONFIG_IMAGE2PIPE_MUXER
236 .
name =
"image2pipe",
244 };
245 #endif
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
#define LIBAVUTIL_VERSION_INT
#define AVIO_FLAG_WRITE
write-only
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
Copy the settings of the source AVCodecContext into the destination AVCodecContext.
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
static int query_codec(enum AVCodecID id, int std_compliance)
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
int id
Format-specific stream ID.
AVStream * avformat_new_stream(AVFormatContext *s, const AVCodec *c)
Add a new stream to a media file.
AVStream ** streams
A list of all streams in the file.
static const AVOption muxoptions[]
static int write_header(AVFormatContext *s)
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
struct AVOutputFormat * oformat
The output container format.
static int write_packet(AVFormatContext *s, AVPacket *pkt)
AVCodecID
Identify the syntax and semantics of the bitstream.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
attribute_deprecated int av_dup_packet(AVPacket *pkt)
simple assert() macros that are a bit more flexible than ISO C assert().
size_t av_strlcpy(char *dst, const char *src, size_t size)
Copy the string src to dst, but no more than size - 1 bytes, and null-terminate dst.
AVCodecContext * codec
Codec context associated with this stream.
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static av_always_inline void update(SilenceDetectContext *s, AVFrame *insamples, int is_silence, int64_t nb_samples_notify, AVRational time_base)
uint8_t nb_components
The number of components each pixel has, (1-4)
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
char filename[1024]
input or output filename
av_warn_unused_result int avformat_write_header(AVFormatContext *s, AVDictionary **options)
Allocate the stream private data and write the stream header to an output media file.
int av_strcasecmp(const char *a, const char *b)
Locale-independent case-insensitive compare.
static struct tm * localtime_r(const time_t *clock, struct tm *result)
int width
picture width / height.
int av_get_frame_filename(char *buf, int buf_size, const char *path, int number)
Return in 'buf' the path with 'd' replaced by a number.
AVIOContext * pb
I/O context.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
int av_copy_packet(AVPacket *dst, const AVPacket *src)
Copy packet, including contents.
Describe the class of an AVClass context structure.
#define FF_COMPLIANCE_NORMAL
const IdStrMap ff_img_tags[]
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
int split_planes
use independent file for each Y, U, V plane
void * priv_data
Format private data.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
int depth
Number of bits in the component.
int(* io_open)(struct AVFormatContext *s, AVIOContext **pb, const char *url, int flags, AVDictionary **options)
This structure stores compressed data.
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
#define AV_CEIL_RSHIFT(a, b)