static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)

{

    AVDictionary **meta_in = NULL;

    AVDictionary **meta_out;

    int i, ret = 0;

    char type_in, type_out;

    const char *istream_spec = NULL, *ostream_spec = NULL;

    int idx_in = 0, idx_out = 0;



    parse_meta_type(inspec,  &type_in,  &idx_in,  &istream_spec);

    parse_meta_type(outspec, &type_out, &idx_out, &ostream_spec);



    if (type_in == 'g' || type_out == 'g')

        o->metadata_global_manual = 1;

    if (type_in == 's' || type_out == 's')

        o->metadata_streams_manual = 1;

    if (type_in == 'c' || type_out == 'c')

        o->metadata_chapters_manual = 1;



#define METADATA_CHECK_INDEX(index, nb_elems, desc)\

    if ((index) < 0 || (index) >= (nb_elems)) {\

        av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\

                (desc), (index));\

        exit_program(1);\

    }



#define SET_DICT(type, meta, context, index)\

        switch (type) {\

        case 'g':\

            meta = &context->metadata;\

            break;\

        case 'c':\

            METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\

            meta = &context->chapters[index]->metadata;\

            break;\

        case 'p':\

            METADATA_CHECK_INDEX(index, context->nb_programs, "program")\

            meta = &context->programs[index]->metadata;\

            break;\


        }\



    SET_DICT(type_in, meta_in, ic, idx_in);

    SET_DICT(type_out, meta_out, oc, idx_out);



    /* for input streams choose first matching stream */

    if (type_in == 's') {

        for (i = 0; i < ic->nb_streams; i++) {

            if ((ret = check_stream_specifier(ic, ic->streams[i], istream_spec)) > 0) {

                meta_in = &ic->streams[i]->metadata;

                break;

            } else if (ret < 0)

                exit_program(1);

        }

        if (!meta_in) {

            av_log(NULL, AV_LOG_FATAL, "Stream specifier %s does not match  any streams.\n", istream_spec);

            exit_program(1);

        }

    }



    if (type_out == 's') {

        for (i = 0; i < oc->nb_streams; i++) {

            if ((ret = check_stream_specifier(oc, oc->streams[i], ostream_spec)) > 0) {

                meta_out = &oc->streams[i]->metadata;

                av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);

            } else if (ret < 0)

                exit_program(1);

        }

    } else

        av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);



    return 0;

}
static int copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o)

{

    AVDictionary **meta_in = NULL;

    AVDictionary **meta_out;

    int i, ret = 0;

    char type_in, type_out;

    const char *istream_spec = NULL, *ostream_spec = NULL;

    int idx_in = 0, idx_out = 0;



    parse_meta_type(inspec,  &type_in,  &idx_in,  &istream_spec);

    parse_meta_type(outspec, &type_out, &idx_out, &ostream_spec);



    if (type_in == 'g' || type_out == 'g')

        o->metadata_global_manual = 1;

    if (type_in == 's' || type_out == 's')

        o->metadata_streams_manual = 1;

    if (type_in == 'c' || type_out == 'c')

        o->metadata_chapters_manual = 1;



#define METADATA_CHECK_INDEX(index, nb_elems, desc)\

    if ((index) < 0 || (index) >= (nb_elems)) {\

        av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\

                (desc), (index));\

        exit_program(1);\

    }



#define SET_DICT(type, meta, context, index)\

        switch (type) {\

        case 'g':\

            meta = &context->metadata;\

            break;\

        case 'c':\

            METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\

            meta = &context->chapters[index]->metadata;\

            break;\

        case 'p':\

            METADATA_CHECK_INDEX(index, context->nb_programs, "program")\

            meta = &context->programs[index]->metadata;\

            break;\


        }\



    SET_DICT(type_in, meta_in, ic, idx_in);

    SET_DICT(type_out, meta_out, oc, idx_out);



    

    if (type_in == 's') {

        for (i = 0; i < ic->nb_streams; i++) {

            if ((ret = check_stream_specifier(ic, ic->streams[i], istream_spec)) > 0) {

                meta_in = &ic->streams[i]->metadata;

                break;

            } else if (ret < 0)

                exit_program(1);

        }

        if (!meta_in) {

            av_log(NULL, AV_LOG_FATAL, "Stream specifier %s does not match  any streams.\n", istream_spec);

            exit_program(1);

        }

    }



    if (type_out == 's') {

        for (i = 0; i < oc->nb_streams; i++) {

            if ((ret = check_stream_specifier(oc, oc->streams[i], ostream_spec)) > 0) {

                meta_out = &oc->streams[i]->metadata;

                av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);

            } else if (ret < 0)

                exit_program(1);

        }

    } else

        av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);



    return 0;

}
static int FUNC_0(char *VAR_0, char *VAR_1, AVFormatContext *VAR_2, AVFormatContext *VAR_3, OptionsContext *VAR_4)

{

    AVDictionary **meta_in = NULL;

    AVDictionary **meta_out;

    int VAR_5, VAR_6 = 0;

    char VAR_7, VAR_8;

    const char *VAR_9 = NULL, *VAR_10 = NULL;

    int VAR_11 = 0, VAR_12 = 0;



    parse_meta_type(VAR_1,  &VAR_7,  &VAR_11,  &VAR_9);

    parse_meta_type(VAR_0, &VAR_8, &VAR_12, &VAR_10);



    if (VAR_7 == 'g' || VAR_8 == 'g')

        VAR_4->metadata_global_manual = 1;

    if (VAR_7 == 's' || VAR_8 == 's')

        VAR_4->metadata_streams_manual = 1;

    if (VAR_7 == 'c' || VAR_8 == 'c')

        VAR_4->metadata_chapters_manual = 1;



#define METADATA_CHECK_INDEX(index, nb_elems, desc)\

    if ((index) < 0 || (index) >= (nb_elems)) {\

        av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\

                (desc), (index));\

        exit_program(1);\

    }



#define SET_DICT(type, meta, context, index)\

        switch (type) {\

        case 'g':\

            meta = &context->metadata;\

            break;\

        case 'c':\

            METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\

            meta = &context->chapters[index]->metadata;\

            break;\

        case 'p':\

            METADATA_CHECK_INDEX(index, context->nb_programs, "program")\

            meta = &context->programs[index]->metadata;\

            break;\


        }\



    SET_DICT(VAR_7, meta_in, VAR_3, VAR_11);

    SET_DICT(VAR_8, meta_out, VAR_2, VAR_12);



    

    if (VAR_7 == 's') {

        for (VAR_5 = 0; VAR_5 < VAR_3->nb_streams; VAR_5++) {

            if ((VAR_6 = check_stream_specifier(VAR_3, VAR_3->streams[VAR_5], VAR_9)) > 0) {

                meta_in = &VAR_3->streams[VAR_5]->metadata;

                break;

            } else if (VAR_6 < 0)

                exit_program(1);

        }

        if (!meta_in) {

            av_log(NULL, AV_LOG_FATAL, "Stream specifier %s does not match  any streams.\n", VAR_9);

            exit_program(1);

        }

    }



    if (VAR_8 == 's') {

        for (VAR_5 = 0; VAR_5 < VAR_2->nb_streams; VAR_5++) {

            if ((VAR_6 = check_stream_specifier(VAR_2, VAR_2->streams[VAR_5], VAR_10)) > 0) {

                meta_out = &VAR_2->streams[VAR_5]->metadata;

                av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);

            } else if (VAR_6 < 0)

                exit_program(1);

        }

    } else

        av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE);



    return 0;

}
static int FUNC_0(char *VAR_0, char *VAR_1, AVFormatContext *VAR_2, AVFormatContext *VAR_3, OptionsContext *VAR_4)
{ AVDictionary **meta_in = NULL; AVDictionary **meta_out; int VAR_5, VAR_6 = 0; char VAR_7, VAR_8; const char *VAR_9 = NULL, *VAR_10 = NULL; int VAR_11 = 0, VAR_12 = 0; parse_meta_type(VAR_1,  &VAR_7,  &VAR_11,  &VAR_9); parse_meta_type(VAR_0, &VAR_8, &VAR_12, &VAR_10); if (VAR_7 == 'g' || VAR_8 == 'g')
VAR_4->metadata_global_manual = 1; if (VAR_7 == 's' || VAR_8 == 's')
VAR_4->metadata_streams_manual = 1; if (VAR_7 == 'c' || VAR_8 == 'c')
VAR_4->metadata_chapters_manual = 1; #define METADATA_CHECK_INDEX(index, nb_elems, desc)\
if ((index) < 0 || (index) >= (nb_elems)) {\ av_log(NULL, AV_LOG_FATAL, "Invalid %s index %d while processing metadata maps.\n",\
(desc), (index));\ exit_program(1);\ } #define SET_DICT(type, meta, context, index)\
switch (type) {\ case 'g':\
meta = &context->metadata;\ break;\ case 'c':\
METADATA_CHECK_INDEX(index, context->nb_chapters, "chapter")\
meta = &context->chapters[index]->metadata;\ break;\ case 'p':\
METADATA_CHECK_INDEX(index, context->nb_programs, "program")\
meta = &context->programs[index]->metadata;\ break;\ }\ SET_DICT(VAR_7, meta_in, VAR_3, VAR_11); SET_DICT(VAR_8, meta_out, VAR_2, VAR_12); if (VAR_7 == 's') { for (VAR_5 = 0; VAR_5 < VAR_3->nb_streams; VAR_5++) { if ((VAR_6 = check_stream_specifier(VAR_3, VAR_3->streams[VAR_5], VAR_9)) > 0) { meta_in = &VAR_3->streams[VAR_5]->metadata; break; } else if (VAR_6 < 0) exit_program(1); } if (!meta_in) { av_log(NULL, AV_LOG_FATAL, "Stream specifier %s does not match  any streams.\n", VAR_9); exit_program(1); } } if (VAR_8 == 's') { for (VAR_5 = 0; VAR_5 < VAR_2->nb_streams; VAR_5++) { if ((VAR_6 = check_stream_specifier(VAR_2, VAR_2->streams[VAR_5], VAR_10)) > 0) { meta_out = &VAR_2->streams[VAR_5]->metadata; av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE); } else if (VAR_6 < 0) exit_program(1); } } else av_dict_copy(meta_out, *meta_in, AV_DICT_DONT_OVERWRITE); return 0; }