Revision 7d727f13 libavformat/utils.c

View differences:

libavformat/utils.c
2719 2719
    return 0;
2720 2720
}
2721 2721

  
2722
AVFormatContext *avformat_alloc_output_context(const char *format, AVOutputFormat *oformat, const char *filename){
2723
    AVFormatContext *s= avformat_alloc_context();
2724
    if(!s)
2725
        goto nomem;
2726

  
2727
    if(!oformat){
2728
        if (format) {
2729
            oformat = av_guess_format(format, NULL, NULL);
2730
            if (!oformat) {
2731
                av_log(s, AV_LOG_ERROR, "Requested output format '%s' is not a suitable output format\n", format);
2732
                goto error;
2733
            }
2734
        } else {
2735
            oformat = av_guess_format(NULL, filename, NULL);
2736
            if (!oformat) {
2737
                av_log(s, AV_LOG_ERROR, "Unable to find a suitable output format for '%s'\n",
2738
                        filename);
2739
                goto error;
2740
            }
2741
        }
2742
    }
2743

  
2744
    s->oformat= oformat;
2745
    if (s->oformat->priv_data_size > 0) {
2746
        s->priv_data = av_mallocz(s->oformat->priv_data_size);
2747
        if (!s->priv_data)
2748
            goto nomem;
2749
        if (s->oformat->priv_class) {
2750
            *(const AVClass**)s->priv_data= s->oformat->priv_class;
2751
            av_opt_set_defaults(s->priv_data);
2752
        }
2753
    } else
2754
        s->priv_data = NULL;
2755

  
2756
    if(filename)
2757
        av_strlcpy(s->filename, filename, sizeof(s->filename));
2758
    return s;
2759
nomem:
2760
    av_log(s, AV_LOG_ERROR, "Out of memory\n");
2761
error:
2762
    avformat_free_context(s);
2763
    return NULL;
2764
}
2765

  
2722 2766
static int validate_codec_tag(AVFormatContext *s, AVStream *st)
2723 2767
{
2724 2768
    const AVCodecTag *avctag;

Also available in: Unified diff