38 #include "libavutil/fifo.h"
39 #include "libavutil/mathematics.h"
40 #include "libavutil/intreadwrite.h"
41 #include "libavutil/opt.h"
42 #include "libavutil/timecode.h"
44 #define MAX_AUDIO_FRAME_SIZE 192000 // 1 second of 48khz 32bit audio
61 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
62 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
63 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
64 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
65 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
66 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
67 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
68 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
69 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
70 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
71 { 0xff, 0xff, 0xff, 0x50, 0x51, 0x52, 0x53, 0xff, 0xff },
72 { 0x50, 0x51, 0x52, 0x53, 0xff, 0xff, 0xff, 0xff, 0xff },
92 timecode |= 1<<23 | 1<<15 | 1<<7 | 1<<6;
139 ((tc.tm_mday / 10) << 4) |
142 ((tc.tm_mon / 10) << 4) |
144 buf[4] = (((tc.tm_year % 100) / 10) << 4) |
155 ((tc.tm_sec / 10) << 4) |
158 ((tc.tm_min / 10) << 4) |
161 ((tc.tm_hour / 10) << 4) |
165 buf[1] = buf[2] = buf[3] = buf[4] = 0xff;
172 int i, j, d, of,
size;
177 for (j = 0; j < 9; j++) {
179 for (d = 8; d < 80; d+=2) {
187 frame_ptr += 16 * 80;
197 for (buf = frame; buf < frame + c->
sys->
frame_size; buf += 150 * 80) {
199 for (j = 80; j < 80 * 3; j += 80) {
200 for (k = 6; k < 6 * 8; k += 8)
212 for (j = 80*3 + 3; j < 80*6; j += 80) {
243 for (i = 0; i < c->
n_ast && st != c->
ast[i]; i++);
262 for (i=0; i < c->
n_ast; i++) {
290 c->
ast[0] = c->
ast[1] = NULL;
296 if (vst)
return NULL;
300 if (c->
n_ast > 1)
return NULL;
311 for (i=0; i<c->
n_ast; i++) {
333 for (i=0; i < c->
n_ast; i++) {
352 for (i=0; i < c->
n_ast; i++)
364 "Make sure that you supply exactly two streams:\n"
365 " video: 25fps or 29.97fps, audio: 2ch/48kHz/PCM\n"
366 " (50Mbps allows an optional second audio stream)\n");
int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding) av_const
Rescale a 64-bit integer with specified rounding.
#define DV_MAX_FRAME_SIZE
largest possible DV frame, in bytes (1080i50)
AVDictionaryEntry * av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
AVCodecContext * codec
Codec context associated with this stream.
void av_log(void *avcl, int level, const char *fmt,...) av_printf_format(3
Send the specified message to the log if the level is less than or equal to the current av_log_level...
int av_timecode_init(AVTimecode *tc, AVRational rate, int flags, int frame_start, void *log_ctx)
Init a timecode struct with the passed parameters.
static int dv_write_trailer(struct AVFormatContext *s)
if((e=av_dict_get(options,"", NULL, AV_DICT_IGNORE_SUFFIX)))
int av_fifo_size(AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
AVFifoBuffer * audio_data[2]
static int dv_write_packet(struct AVFormatContext *s, AVPacket *pkt)
uint32_t av_timecode_get_smpte_from_framenum(const AVTimecode *tc, int framenum)
Convert frame number to SMPTE 12M binary representation.
int audio_samples_dist[5]
enum AVPixelFormat pix_fmt
void av_fifo_free(AVFifoBuffer *f)
Free an AVFifoBuffer.
void av_fifo_drain(AVFifoBuffer *f, int size)
Read and discard the specified amount of data from an AVFifoBuffer.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static int dv_audio_frame_size(const DVprofile *sys, int frame)
void * priv_data
Format private data.
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
static void dv_inject_audio(DVMuxContext *c, int channel, uint8_t *frame_ptr)
static int dv_assemble_frame(DVMuxContext *c, AVStream *st, uint8_t *data, int data_size, uint8_t **frame)
int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int(*func)(void *, void *, int))
Feed data from a user-supplied callback to an AVFifoBuffer.
unsigned int nb_streams
A list of all streams in the file.
const DVprofile * avpriv_dv_codec_profile(AVCodecContext *codec)
#define MAX_AUDIO_FRAME_SIZE
struct tm * ff_brktimegm(time_t secs, struct tm *tm)
static const int dv_aaux_packs_dist[12][9]
static void dv_inject_metadata(DVMuxContext *c, uint8_t *frame)
static DVMuxContext * dv_init_mux(AVFormatContext *s)
static uint8_t * av_fifo_peek2(const AVFifoBuffer *f, int offs)
Return a pointer to the data stored in a FIFO buffer at a certain offset.
static int write_trailer(AVFormatContext *s1)
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
enum AVMediaType codec_type
int sample_rate
samples per second
AVOutputFormat ff_dv_muxer
AVIOContext * pb
I/O context.
Describe the class of an AVClass context structure.
rational number numerator/denominator
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
int av_timecode_init_from_string(AVTimecode *tc, AVRational rate, const char *str, void *log_ctx)
Parse timecode representation (hh:mm:ss[:;.
uint8_t frame_buf[DV_MAX_FRAME_SIZE]
static int dv_write_pack(enum dv_pack_type pack_id, DVMuxContext *c, uint8_t *buf,...)
const uint8_t(* audio_shuffle)[9]
int channels
number of audio channels
static void write_header(FFV1Context *f)
This structure stores compressed data.
static int write_packet(AVFormatContext *s1, AVPacket *pkt)
static void dv_delete_mux(DVMuxContext *c)
static int dv_write_header(AVFormatContext *s)