33 #include <stdatomic.h>
73 #if HAVE_SYS_RESOURCE_H
75 #include <sys/types.h>
76 #include <sys/resource.h>
77 #elif HAVE_GETPROCESSTIMES
80 #if HAVE_GETPROCESSMEMORYINFO
84 #if HAVE_SETCONSOLECTRLHANDLER
90 #include <sys/select.h>
95 #include <sys/ioctl.h>
163 static struct termios oldtty;
164 static int restore_tty;
168 static void free_input_threads(
void);
194 uint32_t *pal, *dst2;
202 if (r->
x < 0 || r->
x + r->
w > w || r->
y < 0 || r->
y + r->
h > h) {
204 r->
x, r->
y, r->
w, r->
h, w, h
209 dst += r->
y * dst_linesize + r->
x * 4;
211 pal = (uint32_t *)r->
data[1];
212 for (y = 0; y < r->
h; y++) {
213 dst2 = (uint32_t *)dst;
215 for (x = 0; x < r->
w; x++)
216 *(dst2++) = pal[*(src2++)];
246 int64_t
pts, end_pts;
263 "Impossible to get a blank canvas.\n");
266 dst = frame->
data [0];
268 for (i = 0; i < num_rects; i++)
292 if (pts2 <= ist2->sub2video.last_pts)
297 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
324 tcsetattr (0, TCSANOW, &oldtty);
348 ret = write(2,
"Received > 3 system signals, hard exiting\n",
349 strlen(
"Received > 3 system signals, hard exiting\n"));
355 #if HAVE_SETCONSOLECTRLHANDLER
356 static BOOL WINAPI CtrlHandler(
DWORD fdwCtrlType)
363 case CTRL_BREAK_EVENT:
367 case CTRL_CLOSE_EVENT:
368 case CTRL_LOGOFF_EVENT:
369 case CTRL_SHUTDOWN_EVENT:
392 if (tcgetattr (0, &tty) == 0) {
396 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
397 |INLCR|IGNCR|ICRNL|IXON);
398 tty.c_oflag |= OPOST;
399 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
400 tty.c_cflag &= ~(CSIZE|PARENB);
405 tcsetattr (0, TCSANOW, &tty);
417 signal(SIGPIPE, SIG_IGN);
419 #if HAVE_SETCONSOLECTRLHANDLER
420 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler,
TRUE);
437 n = select(1, &rfds,
NULL,
NULL, &tv);
446 # if HAVE_PEEKNAMEDPIPE
448 static HANDLE input_handle;
451 input_handle = GetStdHandle(STD_INPUT_HANDLE);
452 is_pipe = !GetConsoleMode(input_handle, &dw);
457 if (!PeekNamedPipe(input_handle,
NULL, 0,
NULL, &nchars,
NULL)) {
499 sizeof(frame),
NULL);
507 &sub,
sizeof(sub),
NULL);
586 free_input_threads();
612 "Error closing vstats file, loss of information possible: %s\n",
671 "bench: %8" PRIu64
" user %8" PRIu64
" sys %8" PRIu64
" real %s \n",
685 ost2->
finished |= ost == ost2 ? this_stream : others;
719 "Too many packets buffered for output stream %d:%d.\n",
767 av_log(s,
AV_LOG_WARNING,
"Invalid DTS: %"PRId64
" PTS: %"PRId64
" in output stream %d:%d, replacing by guess\n",
780 if (pkt->
dts < max) {
782 av_log(s, loglevel,
"Non-monotonous DTS in output stream "
783 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
789 av_log(s, loglevel,
"changing to %"PRId64
". This may result "
790 "in incorrect timestamps in the output file.\n",
807 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
874 if (idx < ost->nb_bitstream_filters) {
934 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
956 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
974 int subtitle_out_max_size = 1024 * 1024;
975 int subtitle_out_size, nb, i;
1009 for (i = 0; i < nb; i++) {
1010 unsigned save_num_rects = sub->
num_rects;
1027 subtitle_out_max_size, sub);
1030 if (subtitle_out_size < 0) {
1037 pkt.
size = subtitle_out_size;
1058 int ret, format_video_sync;
1063 int nb_frames, nb0_frames, i;
1064 double delta, delta0;
1074 if (frame_rate.
num > 0 && frame_rate.
den > 0)
1088 if (!next_picture) {
1123 if (delta0 < -0.6) {
1132 switch (format_video_sync) {
1144 }
else if (delta < -1.1)
1146 else if (delta > 1.1) {
1147 nb_frames =
lrintf(delta);
1149 nb0_frames =
lrintf(delta0 - 0.6);
1155 else if (delta > 0.6)
1168 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1178 "*** dropping frame %d from stream %d at ts %"PRId64
"\n",
1181 if (nb_frames > (nb0_frames && ost->
last_dropped) + (nb_frames > nb0_frames)) {
1194 ost->
last_dropped = nb_frames == nb0_frames && next_picture;
1197 for (i = 0; i < nb_frames; i++) {
1203 if (i < nb0_frames && ost->last_frame) {
1206 in_picture = next_picture;
1221 int forced_keyframe = 0;
1248 forced_keyframe = 1;
1254 ff_dlog(
NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
1262 forced_keyframe = 1;
1274 forced_keyframe = 1;
1277 if (forced_keyframe) {
1285 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1306 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1318 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1323 frame_size = pkt.
size;
1360 return -10.0 * log10(d);
1367 double ti1,
bitrate, avg_bitrate;
1382 fprintf(
vstats_file,
"frame= %5d q= %2.1f ", frame_number,
1399 avg_bitrate = (double)(ost->
data_size * 8) / ti1 / 1000.0;
1400 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1401 (
double)ost->
data_size / 1024, ti1, bitrate, avg_bitrate);
1445 char error[1024] =
"";
1466 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(ret));
1489 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
1491 filtered_frame->
pts =
1516 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1535 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1536 uint64_t subtitle_size = 0;
1537 uint64_t data_size = 0;
1538 float percent = -1.0;
1548 default: other_size += ost->
data_size;
break;
1557 if (data_size && total_size>0 && total_size >= data_size)
1558 percent = 100.0 * (total_size - data_size) / data_size;
1560 av_log(
NULL,
AV_LOG_INFO,
"video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
1561 video_size / 1024.0,
1562 audio_size / 1024.0,
1563 subtitle_size / 1024.0,
1564 other_size / 1024.0,
1565 extra_size / 1024.0);
1575 uint64_t total_packets = 0, total_size = 0;
1604 total_packets, total_size);
1609 uint64_t total_packets = 0, total_size = 0;
1638 total_packets, total_size);
1640 if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){
1650 static void print_report(
int is_last_report, int64_t timer_start, int64_t cur_time)
1652 AVBPrint
buf, buf_script;
1657 int frame_number, vid, i;
1660 int64_t
pts = INT64_MIN + 1;
1661 static int64_t last_time = -1;
1662 static int qp_histogram[52];
1663 int hours, mins, secs,
us;
1664 const char *hours_sign;
1668 if (!
print_stats && !is_last_report && !progress_avio)
1671 if (!is_last_report) {
1672 if (last_time == -1) {
1673 last_time = cur_time;
1676 if ((cur_time - last_time) < 500000)
1678 last_time = cur_time;
1681 t = (cur_time-timer_start) / 1000000.0;
1684 oc = output_files[0]->
ctx;
1687 if (total_size <= 0)
1695 ost = output_streams[i];
1702 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1709 fps = t > 1 ? frame_number / t : 0;
1710 av_bprintf(&buf,
"frame=%5d fps=%3.*f q=%3.1f ",
1711 frame_number, fps < 9.95, fps, q);
1712 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1714 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1723 for (j = 0; j < 32; j++)
1729 double error, error_sum = 0;
1730 double scale, scale_sum = 0;
1732 char type[3] = {
'Y',
'U',
'V' };
1734 for (j = 0; j < 3; j++) {
1735 if (is_last_report) {
1736 error = enc->
error[j];
1737 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
1739 error = ost->
error[j];
1746 p =
psnr(error / scale);
1748 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1751 p =
psnr(error_sum / scale_sum);
1753 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1772 hours_sign = (pts < 0) ?
"-" :
"";
1774 bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
1775 speed = t != 0.0 ? (double)pts /
AV_TIME_BASE / t : -1;
1777 if (total_size < 0)
av_bprintf(&buf,
"size=N/A time=");
1778 else av_bprintf(&buf,
"size=%8.0fkB time=", total_size / 1024.0);
1783 hours_sign, hours, mins, secs, (100 * us) /
AV_TIME_BASE);
1790 av_bprintf(&buf,
"bitrate=%6.1fkbits/s", bitrate);
1791 av_bprintf(&buf_script,
"bitrate=%6.1fkbits/s\n", bitrate);
1794 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1795 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1797 av_bprintf(&buf_script,
"out_time_us=N/A\n");
1798 av_bprintf(&buf_script,
"out_time_ms=N/A\n");
1801 av_bprintf(&buf_script,
"out_time_us=%"PRId64
"\n", pts);
1802 av_bprintf(&buf_script,
"out_time_ms=%"PRId64
"\n", pts);
1803 av_bprintf(&buf_script,
"out_time=%s%02d:%02d:%02d.%06d\n",
1804 hours_sign, hours, mins, secs, us);
1817 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1821 const char end = is_last_report ?
'\n' :
'\r';
1823 fprintf(stderr,
"%s %c", buf.str, end);
1831 if (progress_avio) {
1833 is_last_report ?
"end" :
"continue");
1835 FFMIN(buf_script.len, buf_script.size - 1));
1838 if (is_last_report) {
1841 "Error closing progress log, loss of information possible: %s\n",
av_err2str(ret));
1878 char error[1024] =
"";
1881 "Finishing stream %d:%d without any data written to it.\n",
1969 pkt_size = pkt.
size;
2023 ist->
pts < comp_start :
2057 opkt.
dts -= ost_tb_start_time;
2090 char layout_name[256];
2107 if (*got_output || ret<0)
2113 if (*got_output && ist) {
2138 int need_reinit, ret, i;
2153 need_reinit |= ifilter->
width != frame->
width ||
2165 if (need_reinit || !fg->
graph) {
2250 if (ret < 0 && ret !=
AVERROR(EAGAIN))
2265 if (i < ist->nb_filters - 1) {
2277 "Failed to inject frame into filter network: %s\n",
av_err2str(ret));
2299 ret =
decode(avctx, decoded_frame, got_output, pkt);
2312 if (!*got_output || ret < 0)
2330 decoded_frame->
pts = pkt->
pts;
2333 decoded_frame->
pts = ist->
dts;
2340 ist->nb_samples = decoded_frame->nb_samples;
2345 return err < 0 ? err : ret;
2352 int i, ret = 0, err = 0;
2353 int64_t best_effort_timestamp;
2360 if (!eof && pkt && pkt->
size == 0)
2398 "video_delay is larger in decoder than demuxer %d > %d.\n"
2399 "If you want to help, upload a sample "
2400 "of this file to ftp://upload.ffmpeg.org/incoming/ "
2401 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
2409 if (*got_output && ret >= 0) {
2413 av_log(NULL,
AV_LOG_DEBUG,
"Frame parameters mismatch context %d,%d,%d != %d,%d,%d\n",
2414 decoded_frame->
width,
2423 if (!*got_output || ret < 0)
2461 "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64
" best_effort_ts_time:%s keyframe:%d frame_type:%d time_base:%d/%d\n",
2464 best_effort_timestamp,
2478 return err < 0 ? err : ret;
2487 &subtitle, got_output, pkt);
2491 if (ret < 0 || !*got_output) {
2503 if (end < ist->prev_sub.subtitle.end_display_time) {
2505 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
2507 end <= 0 ?
", dropping it" :
"");
2578 int eof_reached = 0;
2613 int64_t duration_dts = 0;
2614 int64_t duration_pts = 0;
2616 int decode_failed = 0;
2627 ret =
decode_video (ist, repeating ?
NULL : &avpkt, &got_output, &duration_pts, !pkt,
2629 if (!repeating || !pkt || got_output) {
2646 if (duration_pts > 0) {
2657 if (!pkt && ret >= 0)
2670 if (decode_failed) {
2753 return !eof_reached;
2765 if (!output_files[i]->header_written)
2774 avc[j] = output_files[i]->
ctx;
2785 printf(
"SDP:\n%s\n", sdp);
2838 "%s hwaccel requested for input stream #%d:%d, "
2839 "but cannot be initialized.\n",
2864 ret = hwaccel->
init(s);
2867 "%s hwaccel requested for input stream #%d:%d, "
2868 "but cannot be initialized.\n", hwaccel->
name,
2905 snprintf(error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2920 av_log(
NULL,
AV_LOG_WARNING,
"Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
2937 snprintf(error, error_len,
"Device setup failed for "
2938 "decoder on input stream #%d:%d : %s",
2948 "Error while opening decoder for input stream "
2971 return FFDIFFSIGN(*(
const int64_t *)a, *(
const int64_t *)b);
2990 "Could not write header for output file #%d "
2991 "(incorrect codec parameters ?): %s\n",
3065 uint32_t codec_tag = par_dst->
codec_tag;
3074 "Error setting up codec context options.\n");
3081 "Error getting reference codec parameters.\n");
3086 unsigned int codec_tag_tmp;
3112 if (
ost->st->
duration <= 0 && ist->st->duration > 0)
3118 if (ist->st->nb_side_data) {
3119 for (i = 0; i < ist->st->nb_side_data; i++) {
3126 memcpy(dst_data, sd_src->
data, sd_src->
size);
3130 if (
ost->rotate_overridden) {
3137 switch (par_dst->codec_type) {
3143 if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id ==
AV_CODEC_ID_MP3)
3144 par_dst->block_align= 0;
3146 par_dst->block_align= 0;
3149 if (
ost->frame_aspect_ratio.num) {
3152 (
AVRational){ par_dst->height, par_dst->width });
3154 "with stream copy may produce invalid files\n");
3156 else if (ist->st->sample_aspect_ratio.num)
3157 sar = ist->st->sample_aspect_ratio;
3159 sar = par_src->sample_aspect_ratio;
3176 int encoder_string_len;
3177 int format_flags = 0;
3199 encoder_string =
av_mallocz(encoder_string_len);
3200 if (!encoder_string)
3206 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
3207 av_strlcat(encoder_string, ost->
enc->name, encoder_string_len);
3219 for (p = kf; *p; p++)
3230 for (i = 0; i <
n; i++) {
3231 char *next = strchr(p,
',');
3236 if (!memcmp(p,
"chapters", 8)) {
3245 "Could not allocate forced key frames array.\n");
3343 "about the input framerate is available. Falling "
3344 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3345 "if you want a different framerate.\n",
3349 if (ost->
enc->supported_framerates && !ost->
force_fps) {
3381 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
3440 if (!enc_ctx->
width) {
3497 snprintf(error, error_len,
"Device setup failed for "
3498 "encoder on output stream #%d:%d : %s",
3504 int input_props = 0, output_props = 0;
3509 if (input_descriptor)
3511 if (output_descriptor)
3513 if (input_props && output_props && input_props != output_props) {
3515 "Subtitle encoding currently only possible from text to text "
3516 "or bitmap to bitmap");
3525 "Error while opening encoder for output stream #%d:%d - "
3526 "maybe incorrect parameters such as bit_rate, rate, width or height",
3538 " It takes bits/s as argument, not kbits/s\n");
3543 "Error initializing the output stream codec context.\n");
3563 memcpy(dst_data, sd_src->
data, sd_src->
size);
3592 if (ost->
st->
duration <= 0 && ist && ist->st->duration > 0)
3596 }
else if (
ost->stream_copy) {
3605 {
"disposition" ,
NULL, 0,
AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit =
"flags" },
3623 static const AVClass class = {
3629 const AVClass *pclass = &
class;
3643 ost->initialized = 1;
3654 InputFile *file = input_files[input_index];
3660 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
3669 int ret = 0, i, j, k;
3673 char error[1024] = {0};
3684 if (fg->
inputs[0]->
ist == input_streams[k])
3702 ost = output_streams[i];
3711 if (output_streams[i]->
filter)
3737 oc = output_files[i]->
ctx;
3749 ist = input_streams[i];
3756 if (nb_filtergraphs > 1)
3764 ost = output_streams[i];
3776 if (nb_filtergraphs > 1)
3798 const char *decoder_name =
"?";
3799 const char *in_codec_name =
"?";
3800 const char *encoder_name =
"?";
3801 const char *out_codec_name =
"?";
3805 decoder_name = in_codec->
name;
3808 in_codec_name = desc->
name;
3809 if (!strcmp(decoder_name, in_codec_name))
3810 decoder_name =
"native";
3814 encoder_name = out_codec->
name;
3817 out_codec_name = desc->
name;
3818 if (!strcmp(encoder_name, out_codec_name))
3819 encoder_name =
"native";
3823 in_codec_name, decoder_name,
3824 out_codec_name, encoder_name);
3873 int64_t opts_min = INT64_MAX;
3882 av_log(
NULL,
AV_LOG_DEBUG,
"cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n");
3887 if (!ost->
finished && opts < opts_min) {
3899 if (tcgetattr(0, &tty) == 0) {
3900 if (on) tty.c_lflag |=
ECHO;
3901 else tty.c_lflag &= ~
ECHO;
3902 tcsetattr(0, TCSANOW, &tty);
3910 static int64_t last_time;
3916 last_time = cur_time;
3933 if (key ==
'c' || key ==
'C'){
3937 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
3940 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3945 fprintf(stderr,
"\n");
3947 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
3949 target, time, command, arg);
3956 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s", i, ret, buf);
3957 }
else if (key ==
'c') {
3958 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
3963 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(ret));
3969 "Parse error, at least 3 arguments were expected, "
3970 "only %d given in string '%s'\n", n, buf);
3973 if (key ==
'd' || key ==
'D'){
3976 debug = input_streams[0]->
st->codec->debug<<1;
3977 if(!debug) debug = 1;
3980 |FF_DEBUG_VIS_QP|FF_DEBUG_VIS_MB_TYPE
3989 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3994 fprintf(stderr,
"\n");
3995 if (k <= 0 || sscanf(buf,
"%d", &debug)!=1)
3996 fprintf(stderr,
"error parsing debug value\n");
3999 input_streams[i]->
st->codec->debug = debug;
4006 fprintf(stderr,
"debug=%d\n", debug);
4009 fprintf(stderr,
"key function\n"
4010 "? show this help\n"
4011 "+ increase verbosity\n"
4012 "- decrease verbosity\n"
4013 "c Send command to first matching filter supporting it\n"
4014 "C Send/Queue command to all matching filters\n"
4015 "D cycle through available debug modes\n"
4016 "h dump packets/hex press to cycle through the 3 states\n"
4018 "s Show QP histogram\n"
4025 static void *input_thread(
void *
arg)
4044 if (flags && ret ==
AVERROR(EAGAIN)) {
4048 "Thread message queue blocking; consider raising the "
4049 "thread_queue_size option (current value: %d)\n",
4050 f->thread_queue_size);
4055 "Unable to send packet to main thread: %s\n",
4066 static void free_input_thread(
int i)
4071 if (!f || !f->in_thread_queue)
4082 static void free_input_threads(
void)
4087 free_input_thread(i);
4090 static int init_input_thread(
int i)
4095 if (nb_input_files == 1)
4100 f->non_blocking = 1;
4102 f->thread_queue_size,
sizeof(
AVPacket));
4107 av_log(
NULL,
AV_LOG_ERROR,
"pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
4115 static int init_input_threads(
void)
4120 ret = init_input_thread(i);
4149 if (nb_input_files > 1)
4150 return get_input_packet_mt(f, pkt);
4159 if (output_streams[i]->unavailable)
4168 input_files[i]->eagain = 0;
4170 output_streams[i]->unavailable = 0;
4181 return tmp_time_base;
4184 ret =
av_compare_ts(*duration, time_base, tmp, tmp_time_base);
4187 return tmp_time_base;
4197 int i, ret, has_audio = 0;
4205 ist = input_streams[ifile->
ist_index + i];
4216 ist = input_streams[ifile->
ist_index + i];
4245 if (ifile->
loop > 0)
4264 int ret, thread_ret, i, j;
4275 if (ret < 0 && ifile->
loop) {
4278 ist = input_streams[ifile->
ist_index + i];
4288 free_input_thread(file_index);
4292 thread_ret = init_input_thread(file_index);
4313 ist = input_streams[ifile->
ist_index + i];
4344 goto discard_packet;
4353 goto discard_packet;
4357 "%s: corrupt input packet in stream %d\n", is->
url, pkt.
stream_index);
4364 "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
4375 int64_t stime, stime2;
4382 int64_t new_start_time = INT64_MAX;
4425 memcpy(dst_data, src_sd->
data, src_sd->
size);
4449 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4479 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4507 av_log(
NULL,
AV_LOG_INFO,
"demuxer+ffmpeg -> ist_index:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
4535 int nb_requests, nb_requests_max = 0;
4553 for (i = 0; i < graph->
nb_inputs; i++) {
4554 ifilter = graph->
inputs[i];
4560 if (nb_requests > nb_requests_max) {
4561 nb_requests_max = nb_requests;
4607 char error[1024] = {0};
4619 }
else if (ost->
filter) {
4659 int64_t timer_start;
4660 int64_t total_packets_written = 0;
4673 if ((ret = init_input_threads()) < 0)
4701 free_input_threads();
4706 ist = input_streams[i];
4717 os = output_files[i]->
ctx;
4718 if (!output_files[i]->header_written) {
4720 "Nothing was written into output file %d (%s), because "
4721 "at least one of its streams received no packets.\n",
4737 ost = output_streams[i];
4751 ist = input_streams[i];
4767 free_input_threads();
4770 if (output_streams) {
4772 ost = output_streams[i];
4777 "Error closing logfile, loss of information possible: %s\n",
4798 struct rusage rusage;
4800 getrusage(RUSAGE_SELF, &rusage);
4802 (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
4804 (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
4805 #elif HAVE_GETPROCESSTIMES
4807 FILETIME
c, e, k,
u;
4808 proc = GetCurrentProcess();
4809 GetProcessTimes(proc, &c, &e, &k, &u);
4811 ((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
4813 ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
4822 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
4823 struct rusage rusage;
4824 getrusage(RUSAGE_SELF, &rusage);
4825 return (int64_t)rusage.ru_maxrss * 1024;
4826 #elif HAVE_GETPROCESSMEMORYINFO
4828 PROCESS_MEMORY_COUNTERS memcounters;
4829 proc = GetCurrentProcess();
4830 memcounters.cb =
sizeof(memcounters);
4831 GetProcessMemoryInfo(proc, &memcounters,
sizeof(memcounters));
4832 return memcounters.PeakPagefileUsage;
4851 setvbuf(stderr,
NULL,_IONBF,0);
4856 if(argc>1 && !strcmp(argv[1],
"-d")){
4901 int64_t utime, stime, rtime;
4907 "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
4908 utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);
unsigned int nb_chapters
Number of chapters in AVChapter array.
#define AV_CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
void init_dynload(void)
Initialize dynamic library loading.
static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int unqueue)
void av_bsf_free(AVBSFContext **ctx)
Free a bitstream filter context and everything associated with it; write NULL into the supplied point...
static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
int64_t first_dts
Timestamp corresponding to the last dts sync point.
int guess_input_channel_layout(InputStream *ist)
#define ATOMIC_VAR_INIT(value)
const struct AVCodec * codec
enum AVFieldOrder field_order
Video only.
static void output_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int eof)
static void do_subtitle_out(OutputFile *of, OutputStream *ost, AVSubtitle *sub)
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
int64_t avio_size(AVIOContext *s)
Get the filesize.
AVCodecParameters * par_out
Parameters of the output stream.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it...
#define DECODING_FOR_FILTER
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data.
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
static int init_output_stream_streamcopy(OutputStream *ost)
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int x
top left corner of pict, undefined when pict is not set
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
#define atomic_store(object, desired)
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
static void flush(AVCodecContext *avctx)
static void sub2video_flush(InputStream *ist)
uint64_t error[AV_NUM_DATA_POINTERS]
error
char * filters
filtergraph associated to the -filter option
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static int process_input(int file_index)
int64_t forced_kf_ref_pts
static int init_output_stream(OutputStream *ost, char *error, int error_len)
static atomic_int transcode_init_done
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
int64_t pos
byte position in stream, -1 if unknown
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Memory buffer source API.
void av_log_set_level(int level)
Set the log level.
AVRational sample_aspect_ratio
Video only.
int avcodec_receive_packet(AVCodecContext *avctx, AVPacket *avpkt)
Read encoded data from the encoder.
enum AVCodecID codec_id
Specific type of the encoded data (the codec used).
void sub2video_update(InputStream *ist, AVSubtitle *sub)
const struct AVBitStreamFilter * filter
The bitstream filter this context is an instance of.
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
The bitstream filter state.
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
int index
stream index in AVFormatContext
static int64_t getmaxrss(void)
int max_muxing_queue_size
const char * av_default_item_name(void *ptr)
Return the context name.
#define us(width, name, range_min, range_max, subs,...)
static InputStream * get_input_stream(OutputStream *ost)
void hw_device_free_all(void)
#define AVIO_FLAG_WRITE
write-only
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
#define AV_CODEC_PROP_TEXT_SUB
Subtitle codec is text based.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
static int init_output_stream_encode(OutputStream *ost)
static void abort_codec_experimental(AVCodec *c, int encoder)
static int transcode_init(void)
static int compare_int64(const void *a, const void *b)
static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int av_usleep(unsigned usec)
Sleep for a period of time.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
static void report_new_stream(int input_index, AVPacket *pkt)
This struct describes the properties of an encoded stream.
int av_bsf_init(AVBSFContext *ctx)
Prepare the filter for use, after all the parameters and options have been set.
float dts_error_threshold
int64_t start_time
start time in microseconds == AV_TIME_BASE units
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int decode_interrupt_cb(void *ctx)
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.
void av_display_rotation_set(int32_t matrix[9], double angle)
Initialize a transformation matrix describing a pure counterclockwise rotation by the specified angle...
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
static int send_frame_to_filters(InputStream *ist, AVFrame *decoded_frame)
static void update_benchmark(const char *fmt,...)
static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
AVBufferRef * hw_frames_ctx
For hwaccel-format frames, this should be a reference to the AVHWFramesContext describing the frame...
static int check_keyboard_interaction(int64_t cur_time)
Immediately push the frame to the output.
memory buffer sink API for audio and video
static int decode_video(InputStream *ist, AVPacket *pkt, int *got_output, int64_t *duration_pts, int eof, int *decode_failed)
unsigned int nb_stream_indexes
#define AV_LOG_QUIET
Print no output.
int w
width of pict, undefined when pict is not set
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_CODEC_CAP_DELAY
Encoder or decoder requires flushing with NULL input at the end in order to give the complete and cor...
#define av_assert0(cond)
assert() equivalent, that is always enabled.
int av_buffersink_get_sample_rate(const AVFilterContext *ctx)
static uint8_t * subtitle_out
int av_bsf_receive_packet(AVBSFContext *ctx, AVPacket *pkt)
Retrieve a filtered packet.
static void filter(int16_t *output, ptrdiff_t out_stride, int16_t *low, ptrdiff_t low_stride, int16_t *high, ptrdiff_t high_stride, int len, int clip)
static int main_return_code
static int64_t start_time
int copy_initial_nonkeyframes
void register_exit(void(*cb)(int ret))
Register a program-specific cleanup routine.
static int init_output_bsfs(OutputStream *ost)
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
enum AVSampleFormat sample_fmt
audio sample format
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Opaque data information usually continuous.
int av_thread_message_queue_recv(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Receive a message from the queue.
static void sub2video_push_ref(InputStream *ist, int64_t pts)
enum AVCodecID av_codec_get_id(const struct AVCodecTag *const *tags, unsigned int tag)
Get the AVCodecID for the given codec tag tag.
miscellaneous OS support macros and functions.
timestamp utils, mostly useful for debugging/logging purposes
int avformat_transfer_internal_stream_timing_info(const AVOutputFormat *ofmt, AVStream *ost, const AVStream *ist, enum AVTimebaseSource copy_tb)
Transfer internal timing information from one stream to another.
static av_cold int end(AVCodecContext *avctx)
#define media_type_string
int64_t duration
Duration of this packet in AVStream->time_base units, 0 if unknown.
This side data contains a 3x3 transformation matrix describing an affine transformation that needs to...
int av_thread_message_queue_send(AVThreadMessageQueue *mq, void *msg, unsigned flags)
Send a message on the queue.
#define ECHO(name, type, min, max)
static int need_output(void)
int av_frame_ref(AVFrame *dst, const AVFrame *src)
Set up a new reference to the data described by the source frame.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
enum AVPixelFormat pix_fmt
A hardware pixel format which the codec can use.
int av_fifo_space(const AVFifoBuffer *f)
Return the amount of space in bytes in the AVFifoBuffer, that is the amount of data you can write int...
int nb_side_data
The number of elements in the AVStream.side_data array.
static double psnr(double d)
#define u(width, name, range_min, range_max)
AVStream ** streams
A list of all streams in the file.
int avcodec_parameters_to_context(AVCodecContext *codec, const AVCodecParameters *par)
Fill the codec context based on the values from the supplied codec parameters.
int av_codec_get_tag2(const struct AVCodecTag *const *tags, enum AVCodecID id, unsigned int *tag)
Get the codec tag for the given codec id.
static void ifilter_parameters_from_codecpar(InputFilter *ifilter, AVCodecParameters *par)
void av_pkt_dump_log2(void *avcl, int level, const AVPacket *pkt, int dump_payload, const AVStream *st)
Send a nice dump of a packet to the log.
AVRational av_buffersink_get_frame_rate(const AVFilterContext *ctx)
AVDictionaryEntry * av_dict_get(const AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
Get a dictionary entry with matching key.
static double av_q2d(AVRational a)
Convert an AVRational to a double.
static void set_tty_echo(int on)
AVDictionary * resample_opts
void av_packet_move_ref(AVPacket *dst, AVPacket *src)
Move every field in src to dst and reset src.
static void parse_forced_key_frames(char *kf, OutputStream *ost, AVCodecContext *avctx)
static int seek_to_start(InputFile *ifile, AVFormatContext *is)
int avformat_network_init(void)
Do global initialization of network libraries.
char av_get_picture_type_char(enum AVPictureType pict_type)
Return a single letter to describe the given picture type pict_type.
#define AVERROR_EOF
End of file.
static int read_key(void)
static int reap_filters(int flush)
Get and encode new output from any of the filtergraphs, without causing activity. ...
#define AV_LOG_VERBOSE
Detailed information.
static volatile int ffmpeg_exited
int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
Generate an SDP for an RTP session.
static void do_video_stats(OutputStream *ost, int frame_size)
int interlaced_frame
The content of the picture is interlaced.
void parse_loglevel(int argc, char **argv, const OptionDef *options)
Find the '-loglevel' option in the command line args and apply it.
int h
height of pict, undefined when pict is not set
static av_always_inline int64_t avio_tell(AVIOContext *s)
ftell() equivalent for AVIOContext.
int av_reduce(int *dst_num, int *dst_den, int64_t num, int64_t den, int64_t max)
Reduce a fraction.
AVBufferRef * av_buffersink_get_hw_frames_ctx(const AVFilterContext *ctx)
enum AVDiscard discard
selects which program to discard and which to feed to the caller
char * stats_out
pass1 encoding statistics output buffer
void avio_write(AVIOContext *s, const unsigned char *buf, int size)
void * av_realloc_array(void *ptr, size_t nmemb, size_t size)
enum AVChromaLocation chroma_sample_location
This defines the location of chroma samples.
unsigned int * stream_index
int av_buffersink_get_h(const AVFilterContext *ctx)
int av_buffersink_get_format(const AVFilterContext *ctx)
The codec supports this format via the hw_device_ctx interface.
uint64_t channel_layout
Audio only.
static void sub2video_heartbeat(InputStream *ist, int64_t pts)
#define AV_BUFFERSINK_FLAG_NO_REQUEST
Tell av_buffersink_get_buffer_ref() not to request a frame from its input.
struct AVOutputFormat * oformat
The output container format.
#define AV_PKT_FLAG_KEY
The packet contains a keyframe.
attribute_deprecated int av_copy_packet_side_data(AVPacket *dst, const AVPacket *src)
Copy packet side data.
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
void av_dump_format(AVFormatContext *ic, int index, const char *url, int is_output)
Print detailed information about the input or output format, such as duration, bitrate, streams, container, programs, metadata, side data, codec and time base.
Main libavdevice API header.
Callback for checking whether to abort blocking functions.
int avcodec_close(AVCodecContext *avctx)
Close a given AVCodecContext and free all the data associated with it (but not the AVCodecContext its...
AVRational pkt_timebase
Timebase in which pkt_dts/pts and AVPacket.dts/pts are.
static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int *got_output, int *decode_failed)
AVRational av_stream_get_codec_timebase(const AVStream *st)
Get the internal codec timebase from a stream.
libswresample public header
const AVCodecDefault * defaults
Private codec-specific defaults.
int avcodec_parameters_copy(AVCodecParameters *dst, const AVCodecParameters *src)
Copy the contents of src to dst.
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_DICT_MATCH_CASE
Only get an entry with exact-case key match.
int has_b_frames
Size of the frame reordering buffer in the decoder.
static void finish_output_stream(OutputStream *ost)
static void reset_eagain(void)
static AVBufferRef * hw_device_ctx
void av_packet_rescale_ts(AVPacket *pkt, AVRational tb_src, AVRational tb_dst)
Convert valid timing fields (timestamps / durations) in a packet from one timebase to another...
int ffmpeg_parse_options(int argc, char **argv)
FilterGraph ** filtergraphs
const AVIOInterruptCB int_cb
#define atomic_load(object)
int y
top left corner of pict, undefined when pict is not set
static BenchmarkTimeStamps current_time
int av_opt_eval_flags(void *obj, const AVOption *o, const char *val, int *flags_out)
uint8_t * av_packet_get_side_data(const AVPacket *pkt, enum AVPacketSideDataType type, int *size)
Get side information from packet.
static int64_t decode_error_stat[2]
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
#define av_ts2timestr(ts, tb)
Convenience macro, the return value should be used only directly in function arguments but never stan...
int methods
Bit set of AV_CODEC_HW_CONFIG_METHOD_* flags, describing the possible setup methods which can be used...
void av_bprint_init(AVBPrint *buf, unsigned size_init, unsigned size_max)
char * url
input or output URL.
int video_delay
Video only.
int avcodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
Return decoded output data from a decoder.
const char *const forced_keyframes_const_names[]
int capabilities
Codec capabilities.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
int av_fifo_generic_read(AVFifoBuffer *f, void *dest, int buf_size, void(*func)(void *, void *, int))
Feed data from an AVFifoBuffer to a user-supplied callback.
int av_buffersrc_close(AVFilterContext *ctx, int64_t pts, unsigned flags)
Close the buffer source after EOF.
void av_dict_free(AVDictionary **pm)
Free all the memory allocated for an AVDictionary struct and all keys and values. ...
preferred ID for decoding MPEG audio layer 1, 2 or 3
enum AVMediaType codec_type
General type of the encoded data.
AVBufferRef * buf
A reference to the reference-counted buffer where the packet data is stored.
int flags
AV_CODEC_FLAG_*.
int av_opt_set_int(void *obj, const char *name, int64_t val, int search_flags)
#define AV_LOG_SKIP_REPEATED
Skip repeated messages, this requires the user app to use av_log() instead of (f)printf as the 2 woul...
Round to nearest and halfway cases away from zero.
AVRational time_base_in
The timebase used for the timestamps of the input packets.
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
simple assert() macros that are a bit more flexible than ISO C assert().
enum AVPacketSideDataType type
int av_log_get_level(void)
Get the current log level.
const char * name
Name of the codec implementation.
static int check_recording_time(OutputStream *ost)
int(* init)(AVCodecContext *s)
void remove_avoptions(AVDictionary **a, AVDictionary *b)
int hw_device_setup_for_encode(OutputStream *ost)
AVRational avg_frame_rate
Average framerate.
New fields can be added to the end with minor version bumps.
int attribute_align_arg av_buffersink_get_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Get a frame with filtered data from sink and put it in frame.
void avcodec_parameters_free(AVCodecParameters **par)
Free an AVCodecParameters instance and everything associated with it and write NULL to the supplied p...
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.
float frame_drop_threshold
#define AV_CODEC_CAP_VARIABLE_FRAME_SIZE
Audio encoder supports receiving a different number of samples in each call.
int flags
A combination of AV_PKT_FLAG values.
const AVCodecDescriptor * avcodec_descriptor_get(enum AVCodecID id)
uint64_t channel_layout
Audio channel layout.
int av_compare_ts(int64_t ts_a, AVRational tb_a, int64_t ts_b, AVRational tb_b)
Compare two timestamps each in its own time base.
uint32_t end_display_time
int64_t pts
Same as packet pts, in AV_TIME_BASE.
static void check_decode_result(InputStream *ist, int *got_output, int ret)
uint64_t channel_layout
Channel layout of the audio data.
int props
Codec properties, a combination of AV_CODEC_PROP_* flags.
AVRational frame_aspect_ratio
static int ifilter_send_eof(InputFilter *ifilter, int64_t pts)
const AVOption * av_opt_find(void *obj, const char *name, const char *unit, int opt_flags, int search_flags)
Look for an option in an object.
#define FFDIFFSIGN(x, y)
Comparator.
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
unsigned int nb_streams
Number of elements in AVFormatContext.streams.
static int nb_frames_drop
A bitmap, pict will be set.
int seekable
A combination of AVIO_SEEKABLE_ flags or 0 when the stream is not seekable.
int void avio_flush(AVIOContext *s)
Force flushing of buffered data.
int channels
number of audio channels, only used for audio.
audio channel layout utility functions
enum AVPictureType pict_type
Picture type of the frame.
static int transcode(void)
#define AV_CODEC_FLAG_BITEXACT
Use only bitexact stuff (except (I)DCT).
int flags
Frame flags, a combination of AV_FRAME_FLAGS.
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
int64_t av_rescale(int64_t a, int64_t b, int64_t c)
Rescale a 64-bit integer with rounding to nearest.
#define AV_TIME_BASE
Internal time base represented as integer.
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.
AVPacketSideData * coded_side_data
Additional data associated with the entire coded stream.
uint64_t * channel_layouts
void av_log_set_callback(void(*callback)(void *, int, const char *, va_list))
Set the logging callback.
attribute_deprecated int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
Copy the settings of the source AVCodecContext into the destination AVCodecContext.
This side data contains quality related information from the encoder.
#define AV_DICT_DONT_STRDUP_VAL
Take ownership of a value that's been allocated with av_malloc() or another memory allocation functio...
struct OutputStream * ost
int width
picture width / height.
AVBufferRef * hw_frames_ctx
A reference to the AVHWFramesContext describing the input (for encoding) or output (decoding) frames...
AVRational time_base_out
The timebase used for the timestamps of the output packets.
int hw_device_setup_for_decode(InputStream *ist)
double forced_keyframes_expr_const_values[FKF_NB]
int av_packet_make_refcounted(AVPacket *pkt)
Ensure the data described by a given packet is reference counted.
int av_bsf_send_packet(AVBSFContext *ctx, AVPacket *pkt)
Submit a packet for filtering.
#define AV_FRAME_FLAG_CORRUPT
The frame data may be corrupted, e.g.
#define av_err2str(errnum)
Convenience macro, the return value should be used only directly in function arguments but never stan...
#define AV_CODEC_FLAG_PSNR
error[?] variables will be set during encoding.
int ifilter_parameters_from_frame(InputFilter *ifilter, const AVFrame *frame)
#define AV_CODEC_FLAG_PASS1
Use internal 2pass ratecontrol in first pass mode.
static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output, int *decode_failed)
static av_always_inline int pthread_join(pthread_t thread, void **value_ptr)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
int quality
quality (between 1 (good) and FF_LAMBDA_MAX (bad))
static void term_exit_sigsafe(void)
int audio_channels_mapped
uint8_t * av_stream_new_side_data(AVStream *stream, enum AVPacketSideDataType type, int size)
Allocate new information from stream.
int ticks_per_frame
For some codecs, the time base is closer to the field rate than the frame rate.
#define AVFILTER_CMD_FLAG_ONE
Stop once a filter understood the command (for target=all for example), fast filters are favored auto...
static uint32_t codec_flags(enum AVCodecID codec_id)
const char program_name[]
program name, defined by the program for show_version().
#define AVERROR_EXIT
Immediate exit was requested; the called function should not be restarted.
uint8_t * data[4]
data+linesize for the bitmap of this subtitle.
static int got_eagain(void)
static void error(const char *err)
AVFrame * av_frame_clone(const AVFrame *src)
Create a new frame that references the same data as src.
#define AVERROR_EXPERIMENTAL
Requested feature is flagged experimental. Set strict_std_compliance if you really want to use it...
#define FF_ARRAY_ELEMS(a)
const char * avcodec_get_name(enum AVCodecID id)
Get the name of a codec.
void exit_program(int ret)
Wraps exit with a program-specific cleanup routine.
void av_get_channel_layout_string(char *buf, int buf_size, int nb_channels, uint64_t channel_layout)
Return a description of a channel layout.
void avcodec_flush_buffers(AVCodecContext *avctx)
Reset the internal decoder state / flush internal buffers.
#define AVERROR_PATCHWELCOME
Not yet implemented in FFmpeg, patches welcome.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames...
static BenchmarkTimeStamps get_benchmark_time_stamps(void)
int avcodec_send_packet(AVCodecContext *avctx, const AVPacket *avpkt)
Supply raw packet data as input to a decoder.
static int ifilter_has_all_input_formats(FilterGraph *fg)
int avformat_network_deinit(void)
Undo the initialization done by avformat_network_init.
int frame_size
Number of samples per channel in an audio frame.
static av_always_inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
static int check_init_output_file(OutputFile *of, int file_index)
static int sub2video_get_blank_frame(InputStream *ist)
static void set_encoder_id(OutputFile *of, OutputStream *ost)
#define AV_LOG_INFO
Standard information.
AVRational av_buffersink_get_sample_aspect_ratio(const AVFilterContext *ctx)
struct InputStream * sync_ist
#define AV_BPRINT_SIZE_AUTOMATIC
int avcodec_default_get_buffer2(AVCodecContext *s, AVFrame *frame, int flags)
The default callback for AVCodecContext.get_buffer2().
enum AVMediaType codec_type
int64_t pkt_duration
duration of the corresponding packet, expressed in AVStream->time_base units, 0 if unknown...
void av_thread_message_queue_set_err_send(AVThreadMessageQueue *mq, int err)
Set the sending error code.
void avcodec_free_context(AVCodecContext **avctx)
Free the codec context and everything associated with it and write NULL to the provided pointer...
static int init_input_stream(int ist_index, char *error, int error_len)
void av_expr_free(AVExpr *e)
Free a parsed expression previously created with av_expr_parse().
int av_fifo_size(const AVFifoBuffer *f)
Return the amount of data in bytes in the AVFifoBuffer, that is the amount of data you can read from ...
#define AV_TIME_BASE_Q
Internal time base represented as fractional value.
int av_opt_set_dict(void *obj, AVDictionary **options)
Set all the options from a given dictionary on an object.
static void sub2video_copy_rect(uint8_t *dst, int dst_linesize, int w, int h, AVSubtitleRect *r)
int sample_rate
samples per second
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
AVIOContext * pb
I/O context.
int64_t av_rescale_delta(AVRational in_tb, int64_t in_ts, AVRational fs_tb, int duration, int64_t *last, AVRational out_tb)
Rescale a timestamp while preserving known durations.
int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size)
Resize an AVFifoBuffer.
AVFifoBuffer * muxing_queue
static AVRational av_make_q(int num, int den)
Create an AVRational.
static void print_sdp(void)
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
uint64_t av_buffersink_get_channel_layout(const AVFilterContext *ctx)
const AVCodecHWConfig * avcodec_get_hw_config(const AVCodec *codec, int index)
Retrieve supported hardware configurations for a codec.
main external API structure.
void av_packet_unref(AVPacket *pkt)
Wipe the packet.
uint8_t * data
The data buffer.
static void ffmpeg_cleanup(int ret)
static int command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
void avsubtitle_free(AVSubtitle *sub)
Free all allocated data in the given subtitle struct.
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
const char * attachment_filename
static int check_output_constraints(InputStream *ist, OutputStream *ost)
int avfilter_graph_request_oldest(AVFilterGraph *graph)
Request a frame on the oldest sink link.
a very simple circular buffer FIFO implementation
int avcodec_send_frame(AVCodecContext *avctx, const AVFrame *frame)
Supply a raw video or audio frame to the encoder.
#define AV_CODEC_PROP_BITMAP_SUB
Subtitle codec is bitmap based Decoded AVSubtitle data can be read from the AVSubtitleRect->pict fiel...
void assert_avoptions(AVDictionary *m)
Perform non-blocking operation.
int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
Set the given entry in *pm, overwriting an existing entry.
Replacements for frequently missing libm functions.
static int transcode_from_filter(FilterGraph *graph, InputStream **best_ist)
Perform a step of transcoding for the specified filter graph.
#define VSYNC_PASSTHROUGH
Describe the class of an AVClass context structure.
int sample_rate
Sample rate of the audio data.
int configure_filtergraph(FilterGraph *fg)
enum AVPixelFormat(* get_format)(struct AVCodecContext *s, const enum AVPixelFormat *fmt)
callback to negotiate the pixelFormat
OutputStream ** output_streams
const char * av_hwdevice_get_type_name(enum AVHWDeviceType type)
Get the string name of an AVHWDeviceType.
enum AVMediaType av_buffersink_get_type(const AVFilterContext *ctx)
int av_find_nearest_q_idx(AVRational q, const AVRational *q_list)
Find the value in a list of rationals nearest a given reference rational.
#define FF_DEBUG_DCT_COEFF
Rational number (pair of numerator and denominator).
int av_thread_message_queue_alloc(AVThreadMessageQueue **mq, unsigned nelem, unsigned elsize)
Allocate a new message queue.
#define ABORT_ON_FLAG_EMPTY_OUTPUT
int avcodec_parameters_from_context(AVCodecParameters *par, const AVCodecContext *codec)
Fill the parameters struct based on the values from the supplied codec context.
int64_t parse_time_or_die(const char *context, const char *timestr, int is_duration)
Parse a string specifying a time and return its corresponding value as a number of microseconds...
This struct describes a set or pool of "hardware" frames (i.e.
int filtergraph_is_simple(FilterGraph *fg)
discard useless packets like 0 size packets in avi
int avio_open2(AVIOContext **s, const char *url, int flags, const AVIOInterruptCB *int_cb, AVDictionary **options)
Create and initialize a AVIOContext for accessing the resource indicated by url.
int av_buffersink_get_w(const AVFilterContext *ctx)
int(* get_buffer2)(struct AVCodecContext *s, AVFrame *frame, int flags)
This callback is called at the beginning of each frame to get data buffer(s) for it.
static void init_encoder_time_base(OutputStream *ost, AVRational default_time_base)
const char * name
Name of the codec described by this descriptor.
int avcodec_open2(AVCodecContext *avctx, const AVCodec *codec, AVDictionary **options)
Initialize the AVCodecContext to use the given AVCodec.
int64_t best_effort_timestamp
frame timestamp estimated using various heuristics, in stream time base
int frame_bits_per_raw_sample
void avformat_free_context(AVFormatContext *s)
Free an AVFormatContext and all its streams.
unsigned av_buffersrc_get_nb_failed_requests(AVFilterContext *buffer_src)
Get the number of failed requests.
static int transcode_step(void)
Run a single step of transcoding.
char * filters_script
filtergraph script associated to the -filter_script option
int decode_error_flags
decode error flags of the frame, set to a combination of FF_DECODE_ERROR_xxx flags if the decoder pro...
int av_get_audio_frame_duration(AVCodecContext *avctx, int frame_bytes)
Return audio frame duration.
int av_read_frame(AVFormatContext *s, AVPacket *pkt)
Return the next frame of a stream.
static AVRational duration_max(int64_t tmp, int64_t *duration, AVRational tmp_time_base, AVRational time_base)
size_t av_strlcat(char *dst, const char *src, size_t size)
Append the string src to the string dst, but to a total length of no more than size - 1 bytes...
static enum AVPixelFormat pix_fmts[]
This struct describes the properties of a single codec described by an AVCodecID. ...
int av_frame_get_buffer(AVFrame *frame, int align)
Allocate new buffer(s) for audio or video data.
static volatile int received_nb_signals
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
int global_quality
Global quality for codecs which cannot change it per frame.
static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others)
int64_t av_gettime_relative(void)
Get the current time in microseconds since some unspecified starting point.
const char * av_get_media_type_string(enum AVMediaType media_type)
Return a string describing the media_type enum, NULL if media_type is unknown.
#define flags(name, subs,...)
void av_thread_message_queue_free(AVThreadMessageQueue **mq)
Free a message queue.
static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat *pix_fmts)
int64_t start_time
Position of the first frame of the component, in AV_TIME_BASE fractional seconds. ...
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
AVExpr * forced_keyframes_pexpr
int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt)
Return number of bytes per sample.
int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp, int flags)
Seek to the keyframe at timestamp.
int64_t duration
Decoding: duration of the stream, in stream time base.
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
int sample_rate
Audio only.
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
void print_error(const char *filename, int err)
Print an error message to stderr, indicating filename and a human readable description of the error c...
struct FilterGraph * graph
const OptionDef options[]
static void print_final_stats(int64_t total_size)
AVIOContext * progress_avio
int main(int argc, char **argv)
AVCodecParameters * ref_par
void av_buffersink_set_frame_size(AVFilterContext *ctx, unsigned frame_size)
Set the frame size for an audio buffer sink.
#define AV_CODEC_CAP_PARAM_CHANGE
Codec supports changed parameters at any point.
int64_t start_time
Decoding: pts of the first frame of the stream in presentation order, in stream time base...
static AVCodecContext * dec_ctx
int disposition
AV_DISPOSITION_* bit field.
uint32_t start_display_time
AVRational av_add_q(AVRational b, AVRational c)
Add two rationals.
AVBufferRef * av_buffer_ref(AVBufferRef *buf)
Create a new reference to an AVBuffer.
int pts_wrap_bits
number of bits in pts (used for wrapping control)
AVRational time_base
time base in which the start/end timestamps are specified
void av_init_packet(AVPacket *pkt)
Initialize optional fields of a packet with default values.
int thread_safe_callbacks
Set by the client if its custom get_buffer() callback can be called synchronously from another thread...
int64_t nb_frames
number of frames in this stream if known or 0
static FILE * vstats_file
void uninit_opts(void)
Uninitialize the cmdutils option system, in particular free the *_opts contexts and their contents...
int avfilter_graph_send_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, char *res, int res_len, int flags)
Send a command to one or more filter instances.
int attribute_align_arg av_buffersrc_add_frame_flags(AVFilterContext *ctx, AVFrame *frame, int flags)
Add a frame to the buffer source.
#define AV_PKT_FLAG_CORRUPT
The packet content is corrupted.
static void do_video_out(OutputFile *of, OutputStream *ost, AVFrame *next_picture, double sync_ipts)
struct AVInputFormat * iformat
The input container format.
void avformat_close_input(AVFormatContext **s)
Close an opened input AVFormatContext.
#define AV_CODEC_FLAG_PASS2
Use internal 2pass ratecontrol in second pass mode.
Flag telling rescaling functions to pass INT64_MIN/MAX through unchanged, avoiding special cases for ...
int hwaccel_decode_init(AVCodecContext *avctx)
AVFifoBuffer * av_fifo_alloc(unsigned int size)
Initialize an AVFifoBuffer.
Keep a reference to the frame.
int top_field_first
If the content is interlaced, is top field displayed first.
#define av_ts2str(ts)
Convenience macro, the return value should be used only directly in function arguments but never stan...
float dts_delta_threshold
double av_expr_eval(AVExpr *e, const double *const_values, void *opaque)
Evaluate a previously parsed expression.
int channels
number of audio channels
int av_buffersink_get_channels(const AVFilterContext *ctx)
static int get_buffer(AVCodecContext *s, AVFrame *frame, int flags)
void av_log_set_flags(int arg)
int key_frame
1 -> keyframe, 0-> not
#define FF_QP2LAMBDA
factor to convert from H.263 QP to lambda
static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
static void do_audio_out(OutputFile *of, OutputStream *ost, AVFrame *frame)
int64_t dts
Decompression timestamp in AVStream->time_base units; the time at which the packet is decompressed...
AVRational av_mul_q(AVRational b, AVRational c)
Multiply two rationals.
AVDictionary * encoder_opts
int64_t av_get_default_channel_layout(int nb_channels)
Return default channel layout for a given number of channels.
int av_write_trailer(AVFormatContext *s)
Write the stream trailer to an output media file and free the file private data.
const int program_birth_year
program birth year, defined by the program for show_banner()
int repeat_pict
This field is used for proper frame duration computation in lavf.
enum AVFieldOrder field_order
Field order.
static int decode(AVCodecContext *avctx, AVFrame *frame, int *got_frame, AVPacket *pkt)
#define AV_DICT_IGNORE_SUFFIX
Return first entry in a dictionary whose first part corresponds to the search key, ignoring the suffix of the found key string.
static int send_filter_eof(InputStream *ist)
OutputFile ** output_files
#define AV_LOG_FATAL
Something went wrong and recovery is not possible.
void av_fifo_freep(AVFifoBuffer **f)
Free an AVFifoBuffer and reset pointer to NULL.
AVCodecParameters * codecpar
Codec parameters associated with this stream.
#define av_malloc_array(a, b)
int64_t av_rescale_q_rnd(int64_t a, AVRational bq, AVRational cq, enum AVRounding rnd)
Rescale a 64-bit integer by 2 rational numbers with specified rounding.
enum AVHWDeviceType device_type
The device type associated with the configuration.
static void flush_encoders(void)
uint32_t codec_tag
Additional information about the codec (corresponds to the AVI FOURCC).
static volatile int received_sigterm
#define FFSWAP(type, a, b)
static int get_input_packet(InputFile *f, AVPacket *pkt)
uint8_t * av_packet_new_side_data(AVPacket *pkt, enum AVPacketSideDataType type, int size)
Allocate new information of a packet.
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
int depth
Number of bits in the component.
enum AVDiscard discard
Selects which packets can be discarded at will and do not need to be demuxed.
AVRational r_frame_rate
Real base framerate of the stream.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_RL32
AVPixelFormat
Pixel format.
This structure stores compressed data.
int avio_closep(AVIOContext **s)
Close the resource accessed by the AVIOContext *s, free it and set the pointer pointing to it to NULL...
AVCodecParameters * par_in
Parameters of the input stream.
int avcodec_encode_subtitle(AVCodecContext *avctx, uint8_t *buf, int buf_size, const AVSubtitle *sub)
AVRational av_buffersink_get_time_base(const AVFilterContext *ctx)
static OutputStream * choose_output(void)
Select the output stream to process.
int nb_samples
number of audio samples (per channel) described by this frame
static void sigterm_handler(int sig)
int64_t pts
Presentation timestamp in AVStream->time_base units; the time at which the decompressed packet will b...
void * opaque
Private data of the user, can be used to carry app specific stuff.
#define AV_NOPTS_VALUE
Undefined timestamp value.
int avio_printf(AVIOContext *s, const char *fmt,...) av_printf_format(2
int attribute_align_arg av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame)
Add a frame to the buffer source.
InputStream ** input_streams
static unsigned dup_warning
uint8_t pi<< 24) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_U8,(uint64_t)((*(constuint8_t *) pi-0x80U))<< 56) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S16,(uint64_t)(*(constint16_t *) pi)<< 48) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_S32,(uint64_t)(*(constint32_t *) pi)<< 32) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S64,(*(constint64_t *) pi >>56)+0x80) CONV_FUNC(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0f/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S64,*(constint64_t *) pi *(1.0/(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_FLT, llrintf(*(constfloat *) pi *(INT64_C(1)<< 63))) CONV_FUNC(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31)))) CONV_FUNC(AV_SAMPLE_FMT_S64, int64_t, AV_SAMPLE_FMT_DBL, llrint(*(constdouble *) pi *(INT64_C(1)<< 63)))#defineFMT_PAIR_FUNC(out, in) staticconv_func_type *constfmt_pair_to_conv_functions[AV_SAMPLE_FMT_NB *AV_SAMPLE_FMT_NB]={FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_U8), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S16), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S32), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_FLT), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_DBL), FMT_PAIR_FUNC(AV_SAMPLE_FMT_U8, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_S64), FMT_PAIR_FUNC(AV_SAMPLE_FMT_S64, AV_SAMPLE_FMT_S64),};staticvoidcpy1(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, len);}staticvoidcpy2(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 2 *len);}staticvoidcpy4(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 4 *len);}staticvoidcpy8(uint8_t **dst, constuint8_t **src, intlen){memcpy(*dst,*src, 8 *len);}AudioConvert *swri_audio_convert_alloc(enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, constint *ch_map, intflags){AudioConvert *ctx;conv_func_type *f=fmt_pair_to_conv_functions[av_get_packed_sample_fmt(out_fmt)+AV_SAMPLE_FMT_NB *av_get_packed_sample_fmt(in_fmt)];if(!f) returnNULL;ctx=av_mallocz(sizeof(*ctx));if(!ctx) returnNULL;if(channels==1){in_fmt=av_get_planar_sample_fmt(in_fmt);out_fmt=av_get_planar_sample_fmt(out_fmt);}ctx->channels=channels;ctx->conv_f=f;ctx->ch_map=ch_map;if(in_fmt==AV_SAMPLE_FMT_U8||in_fmt==AV_SAMPLE_FMT_U8P) memset(ctx->silence, 0x80, sizeof(ctx->silence));if(out_fmt==in_fmt &&!ch_map){switch(av_get_bytes_per_sample(in_fmt)){case1:ctx->simd_f=cpy1;break;case2:ctx->simd_f=cpy2;break;case4:ctx->simd_f=cpy4;break;case8:ctx->simd_f=cpy8;break;}}if(HAVE_X86ASM &&1) swri_audio_convert_init_x86(ctx, out_fmt, in_fmt, channels);if(ARCH_ARM) swri_audio_convert_init_arm(ctx, out_fmt, in_fmt, channels);if(ARCH_AARCH64) swri_audio_convert_init_aarch64(ctx, out_fmt, in_fmt, channels);returnctx;}voidswri_audio_convert_free(AudioConvert **ctx){av_freep(ctx);}intswri_audio_convert(AudioConvert *ctx, AudioData *out, AudioData *in, intlen){intch;intoff=0;constintos=(out->planar?1:out->ch_count)*out->bps;unsignedmisaligned=0;av_assert0(ctx->channels==out->ch_count);if(ctx->in_simd_align_mask){intplanes=in->planar?in->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) in->ch[ch];misaligned|=m &ctx->in_simd_align_mask;}if(ctx->out_simd_align_mask){intplanes=out->planar?out->ch_count:1;unsignedm=0;for(ch=0;ch< planes;ch++) m|=(intptr_t) out->ch[ch];misaligned|=m &ctx->out_simd_align_mask;}if(ctx->simd_f &&!ctx->ch_map &&!misaligned){off=len &~15;av_assert1(off >=0);av_assert1(off<=len);av_assert2(ctx->channels==SWR_CH_MAX||!in->ch[ctx->channels]);if(off >0){if(out->planar==in->planar){intplanes=out->planar?out->ch_count:1;for(ch=0;ch< planes;ch++){ctx->simd_f(out-> ch ch
static void close_output_stream(OutputStream *ost)
uint8_t * subtitle_header
Header containing style information for text subtitles.