* qatar/master:
Implement fate-rsync target
Make ffmpeg support generic data stream
Conflicts:
cmdutils.h
Merged-by: Michael Niedermayer <michaelni@gmx.at>
| ... | ... |
@@ -280,7 +280,11 @@ fate-seek: $(FATE_SEEK) |
| 280 | 280 |
|
| 281 | 281 |
ifdef SAMPLES |
| 282 | 282 |
FATE += $(FATE_TESTS) |
| 283 |
+fate-rsync: |
|
| 284 |
+ rsync -vaLW rsync://fate-suite.libav.org/fate-suite/ $(SAMPLES) |
|
| 283 | 285 |
else |
| 286 |
+fate-rsync: |
|
| 287 |
+ @echo "use 'make fate-rsync SAMPLES=/path/to/samples' to sync the fate suite" |
|
| 284 | 288 |
$(FATE_TESTS): |
| 285 | 289 |
@echo "SAMPLES not specified, cannot run FATE" |
| 286 | 290 |
endif |
| ... | ... |
@@ -122,7 +122,8 @@ typedef struct {
|
| 122 | 122 |
#define OPT_FUNC2 0x0400 |
| 123 | 123 |
#define OPT_INT64 0x0800 |
| 124 | 124 |
#define OPT_EXIT 0x1000 |
| 125 |
-#define OPT_DUMMY 0x2000 |
|
| 125 |
+#define OPT_DATA 0x2000 |
|
| 126 |
+#define OPT_DUMMY 0x4000 |
|
| 126 | 127 |
union {
|
| 127 | 128 |
void (*func_arg)(const char *); //FIXME passing error code as int return would be nicer then exit() in the func |
| 128 | 129 |
int *int_arg; |
| ... | ... |
@@ -193,6 +193,10 @@ static char *subtitle_codec_name = NULL; |
| 193 | 193 |
static char *subtitle_language = NULL; |
| 194 | 194 |
static unsigned int subtitle_codec_tag = 0; |
| 195 | 195 |
|
| 196 |
+static int data_disable = 0; |
|
| 197 |
+static char *data_codec_name = NULL; |
|
| 198 |
+static unsigned int data_codec_tag = 0; |
|
| 199 |
+ |
|
| 196 | 200 |
static float mux_preload= 0.5; |
| 197 | 201 |
static float mux_max_delay= 0.7; |
| 198 | 202 |
|
| ... | ... |
@@ -211,6 +215,7 @@ static const char *pass_logfilename_prefix; |
| 211 | 211 |
static int audio_stream_copy = 0; |
| 212 | 212 |
static int video_stream_copy = 0; |
| 213 | 213 |
static int subtitle_stream_copy = 0; |
| 214 |
+static int data_stream_copy = 0; |
|
| 214 | 215 |
static int video_sync_method= -1; |
| 215 | 216 |
static int audio_sync_method= 0; |
| 216 | 217 |
static float audio_drift_threshold= 0.1; |
| ... | ... |
@@ -555,6 +560,7 @@ static int ffmpeg_exit(int ret) |
| 555 | 555 |
av_free(video_codec_name); |
| 556 | 556 |
av_free(audio_codec_name); |
| 557 | 557 |
av_free(subtitle_codec_name); |
| 558 |
+ av_free(data_codec_name); |
|
| 558 | 559 |
|
| 559 | 560 |
av_free(video_standard); |
| 560 | 561 |
|
| ... | ... |
@@ -2254,6 +2260,8 @@ static int transcode(AVFormatContext **output_files, |
| 2254 | 2254 |
codec->width = icodec->width; |
| 2255 | 2255 |
codec->height = icodec->height; |
| 2256 | 2256 |
break; |
| 2257 |
+ case AVMEDIA_TYPE_DATA: |
|
| 2258 |
+ break; |
|
| 2257 | 2259 |
default: |
| 2258 | 2260 |
abort(); |
| 2259 | 2261 |
} |
| ... | ... |
@@ -3016,6 +3024,11 @@ static void opt_subtitle_codec(const char *arg) |
| 3016 | 3016 |
opt_codec(&subtitle_stream_copy, &subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, arg); |
| 3017 | 3017 |
} |
| 3018 | 3018 |
|
| 3019 |
+static void opt_data_codec(const char *arg) |
|
| 3020 |
+{
|
|
| 3021 |
+ opt_codec(&data_stream_copy, &data_codec_name, AVMEDIA_TYPE_DATA, arg); |
|
| 3022 |
+} |
|
| 3023 |
+ |
|
| 3019 | 3024 |
static int opt_codec_tag(const char *opt, const char *arg) |
| 3020 | 3025 |
{
|
| 3021 | 3026 |
char *tail; |
| ... | ... |
@@ -3409,15 +3422,19 @@ static void opt_input_file(const char *filename) |
| 3409 | 3409 |
av_freep(&subtitle_codec_name); |
| 3410 | 3410 |
} |
| 3411 | 3411 |
|
| 3412 |
-static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr, |
|
| 3413 |
- int *has_subtitle_ptr) |
|
| 3412 |
+static void check_inputs(int *has_video_ptr, |
|
| 3413 |
+ int *has_audio_ptr, |
|
| 3414 |
+ int *has_subtitle_ptr, |
|
| 3415 |
+ int *has_data_ptr) |
|
| 3414 | 3416 |
{
|
| 3415 |
- int has_video, has_audio, has_subtitle, i, j; |
|
| 3417 |
+ int has_video, has_audio, has_subtitle, has_data, i, j; |
|
| 3416 | 3418 |
AVFormatContext *ic; |
| 3417 | 3419 |
|
| 3418 | 3420 |
has_video = 0; |
| 3419 | 3421 |
has_audio = 0; |
| 3420 | 3422 |
has_subtitle = 0; |
| 3423 |
+ has_data = 0; |
|
| 3424 |
+ |
|
| 3421 | 3425 |
for(j=0;j<nb_input_files;j++) {
|
| 3422 | 3426 |
ic = input_files[j]; |
| 3423 | 3427 |
for(i=0;i<ic->nb_streams;i++) {
|
| ... | ... |
@@ -3435,6 +3452,7 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr, |
| 3435 | 3435 |
case AVMEDIA_TYPE_DATA: |
| 3436 | 3436 |
case AVMEDIA_TYPE_ATTACHMENT: |
| 3437 | 3437 |
case AVMEDIA_TYPE_UNKNOWN: |
| 3438 |
+ has_data = 1; |
|
| 3438 | 3439 |
break; |
| 3439 | 3440 |
default: |
| 3440 | 3441 |
abort(); |
| ... | ... |
@@ -3444,6 +3462,7 @@ static void check_audio_video_sub_inputs(int *has_video_ptr, int *has_audio_ptr, |
| 3444 | 3444 |
*has_video_ptr = has_video; |
| 3445 | 3445 |
*has_audio_ptr = has_audio; |
| 3446 | 3446 |
*has_subtitle_ptr = has_subtitle; |
| 3447 |
+ *has_data_ptr = has_data; |
|
| 3447 | 3448 |
} |
| 3448 | 3449 |
|
| 3449 | 3450 |
static void new_video_stream(AVFormatContext *oc, int file_idx) |
| ... | ... |
@@ -3676,6 +3695,45 @@ static void new_audio_stream(AVFormatContext *oc, int file_idx) |
| 3676 | 3676 |
audio_stream_copy = 0; |
| 3677 | 3677 |
} |
| 3678 | 3678 |
|
| 3679 |
+static void new_data_stream(AVFormatContext *oc, int file_idx) |
|
| 3680 |
+{
|
|
| 3681 |
+ AVStream *st; |
|
| 3682 |
+ AVOutputStream *ost; |
|
| 3683 |
+ AVCodec *codec=NULL; |
|
| 3684 |
+ AVCodecContext *data_enc; |
|
| 3685 |
+ |
|
| 3686 |
+ st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); |
|
| 3687 |
+ if (!st) {
|
|
| 3688 |
+ fprintf(stderr, "Could not alloc stream\n"); |
|
| 3689 |
+ ffmpeg_exit(1); |
|
| 3690 |
+ } |
|
| 3691 |
+ ost = new_output_stream(oc, file_idx); |
|
| 3692 |
+ data_enc = st->codec; |
|
| 3693 |
+ output_codecs = grow_array(output_codecs, sizeof(*output_codecs), &nb_output_codecs, nb_output_codecs + 1); |
|
| 3694 |
+ if (!data_stream_copy) {
|
|
| 3695 |
+ fprintf(stderr, "Data stream encoding not supported yet (only streamcopy)\n"); |
|
| 3696 |
+ ffmpeg_exit(1); |
|
| 3697 |
+ } |
|
| 3698 |
+ avcodec_get_context_defaults3(st->codec, codec); |
|
| 3699 |
+ |
|
| 3700 |
+ data_enc->codec_type = AVMEDIA_TYPE_DATA; |
|
| 3701 |
+ |
|
| 3702 |
+ if (data_codec_tag) |
|
| 3703 |
+ data_enc->codec_tag= data_codec_tag; |
|
| 3704 |
+ |
|
| 3705 |
+ if (oc->oformat->flags & AVFMT_GLOBALHEADER) {
|
|
| 3706 |
+ data_enc->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
| 3707 |
+ avcodec_opts[AVMEDIA_TYPE_DATA]->flags |= CODEC_FLAG_GLOBAL_HEADER; |
|
| 3708 |
+ } |
|
| 3709 |
+ if (data_stream_copy) {
|
|
| 3710 |
+ st->stream_copy = 1; |
|
| 3711 |
+ } |
|
| 3712 |
+ |
|
| 3713 |
+ data_disable = 0; |
|
| 3714 |
+ av_freep(&data_codec_name); |
|
| 3715 |
+ data_stream_copy = 0; |
|
| 3716 |
+} |
|
| 3717 |
+ |
|
| 3679 | 3718 |
static void new_subtitle_stream(AVFormatContext *oc, int file_idx) |
| 3680 | 3719 |
{
|
| 3681 | 3720 |
AVStream *st; |
| ... | ... |
@@ -3746,6 +3804,7 @@ static int opt_new_stream(const char *opt, const char *arg) |
| 3746 | 3746 |
if (!strcmp(opt, "newvideo" )) new_video_stream (oc, file_idx); |
| 3747 | 3747 |
else if (!strcmp(opt, "newaudio" )) new_audio_stream (oc, file_idx); |
| 3748 | 3748 |
else if (!strcmp(opt, "newsubtitle")) new_subtitle_stream(oc, file_idx); |
| 3749 |
+ else if (!strcmp(opt, "newdata" )) new_data_stream (oc, file_idx); |
|
| 3749 | 3750 |
else av_assert0(0); |
| 3750 | 3751 |
return 0; |
| 3751 | 3752 |
} |
| ... | ... |
@@ -3776,8 +3835,8 @@ static int opt_streamid(const char *opt, const char *arg) |
| 3776 | 3776 |
static void opt_output_file(const char *filename) |
| 3777 | 3777 |
{
|
| 3778 | 3778 |
AVFormatContext *oc; |
| 3779 |
- int err, use_video, use_audio, use_subtitle; |
|
| 3780 |
- int input_has_video, input_has_audio, input_has_subtitle; |
|
| 3779 |
+ int err, use_video, use_audio, use_subtitle, use_data; |
|
| 3780 |
+ int input_has_video, input_has_audio, input_has_subtitle, input_has_data; |
|
| 3781 | 3781 |
AVFormatParameters params, *ap = ¶ms; |
| 3782 | 3782 |
AVOutputFormat *file_oformat; |
| 3783 | 3783 |
|
| ... | ... |
@@ -3805,28 +3864,36 @@ static void opt_output_file(const char *filename) |
| 3805 | 3805 |
use_video = file_oformat->video_codec != CODEC_ID_NONE || video_stream_copy || video_codec_name; |
| 3806 | 3806 |
use_audio = file_oformat->audio_codec != CODEC_ID_NONE || audio_stream_copy || audio_codec_name; |
| 3807 | 3807 |
use_subtitle = file_oformat->subtitle_codec != CODEC_ID_NONE || subtitle_stream_copy || subtitle_codec_name; |
| 3808 |
+ use_data = data_stream_copy || data_codec_name; /* XXX once generic data codec will be available add a ->data_codec reference and use it here */ |
|
| 3808 | 3809 |
|
| 3809 | 3810 |
/* disable if no corresponding type found and at least one |
| 3810 | 3811 |
input file */ |
| 3811 | 3812 |
if (nb_input_files > 0) {
|
| 3812 |
- check_audio_video_sub_inputs(&input_has_video, &input_has_audio, |
|
| 3813 |
- &input_has_subtitle); |
|
| 3813 |
+ check_inputs(&input_has_video, |
|
| 3814 |
+ &input_has_audio, |
|
| 3815 |
+ &input_has_subtitle, |
|
| 3816 |
+ &input_has_data); |
|
| 3817 |
+ |
|
| 3814 | 3818 |
if (!input_has_video) |
| 3815 | 3819 |
use_video = 0; |
| 3816 | 3820 |
if (!input_has_audio) |
| 3817 | 3821 |
use_audio = 0; |
| 3818 | 3822 |
if (!input_has_subtitle) |
| 3819 | 3823 |
use_subtitle = 0; |
| 3824 |
+ if (!input_has_data) |
|
| 3825 |
+ use_data = 0; |
|
| 3820 | 3826 |
} |
| 3821 | 3827 |
|
| 3822 | 3828 |
/* manual disable */ |
| 3823 | 3829 |
if (audio_disable) use_audio = 0; |
| 3824 | 3830 |
if (video_disable) use_video = 0; |
| 3825 | 3831 |
if (subtitle_disable) use_subtitle = 0; |
| 3832 |
+ if (data_disable) use_data = 0; |
|
| 3826 | 3833 |
|
| 3827 | 3834 |
if (use_video) new_video_stream(oc, nb_output_files); |
| 3828 | 3835 |
if (use_audio) new_audio_stream(oc, nb_output_files); |
| 3829 | 3836 |
if (use_subtitle) new_subtitle_stream(oc, nb_output_files); |
| 3837 |
+ if (use_data) new_data_stream(oc, nb_output_files); |
|
| 3830 | 3838 |
|
| 3831 | 3839 |
oc->timestamp = recording_timestamp; |
| 3832 | 3840 |
|
| ... | ... |
@@ -4236,6 +4303,8 @@ static int opt_preset(const char *opt, const char *arg) |
| 4236 | 4236 |
opt_video_codec(tmp2); |
| 4237 | 4237 |
}else if(!strcmp(tmp, "scodec")){
|
| 4238 | 4238 |
opt_subtitle_codec(tmp2); |
| 4239 |
+ }else if(!strcmp(tmp, "dcodec")){
|
|
| 4240 |
+ opt_data_codec(tmp2); |
|
| 4239 | 4241 |
}else if(opt_default(tmp, tmp2) < 0){
|
| 4240 | 4242 |
fprintf(stderr, "%s: Invalid option or argument: '%s', parsed as '%s' = '%s'\n", filename, line, tmp, tmp2); |
| 4241 | 4243 |
ffmpeg_exit(1); |
| ... | ... |
@@ -4389,6 +4458,8 @@ static const OptionDef options[] = {
|
| 4389 | 4389 |
{ "vpre", OPT_FUNC2 | HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_preset}, "set the video options to the indicated preset", "preset" },
|
| 4390 | 4390 |
{ "spre", OPT_FUNC2 | HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_preset}, "set the subtitle options to the indicated preset", "preset" },
|
| 4391 | 4391 |
{ "fpre", OPT_FUNC2 | HAS_ARG | OPT_EXPERT, {(void*)opt_preset}, "set options from indicated preset file", "filename" },
|
| 4392 |
+ /* data codec support */ |
|
| 4393 |
+ { "dcodec", HAS_ARG | OPT_DATA, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },
|
|
| 4392 | 4394 |
|
| 4393 | 4395 |
{ "default", OPT_FUNC2 | HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {(void*)opt_default}, "generic catch all option", "" },
|
| 4394 | 4396 |
{ NULL, },
|
| ... | ... |
@@ -603,6 +603,7 @@ void ff_parse_specific_params(AVCodecContext *stream, int *au_rate, int *au_ssiz |
| 603 | 603 |
*au_scale=stream->frame_size; |
| 604 | 604 |
*au_rate= stream->sample_rate; |
| 605 | 605 |
}else if(stream->codec_type == AVMEDIA_TYPE_VIDEO || |
| 606 |
+ stream->codec_type == AVMEDIA_TYPE_DATA || |
|
| 606 | 607 |
stream->codec_type == AVMEDIA_TYPE_SUBTITLE){
|
| 607 | 608 |
*au_scale= stream->time_base.num; |
| 608 | 609 |
*au_rate = stream->time_base.den; |