Merge commit '1e46c63eb72be752e044ba32257d77f35cbd9dac'
* commit '1e46c63eb72be752e044ba32257d77f35cbd9dac': avformat: refactor avformat_write_header Conflicts: libavformat/mux.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
		@@ -199,7 +199,8 @@ static int validate_codec_tag(AVFormatContext *s, AVStream *st)
 | 
				
			|||||||
    return 1;
 | 
					    return 1;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int avformat_write_header(AVFormatContext *s, AVDictionary **options)
 | 
					
 | 
				
			||||||
 | 
					static int init_muxer(AVFormatContext *s, AVDictionary **options)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    int ret = 0, i;
 | 
					    int ret = 0, i;
 | 
				
			||||||
    AVStream *st;
 | 
					    AVStream *st;
 | 
				
			||||||
@@ -317,14 +318,23 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
 | 
				
			|||||||
        av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
 | 
					        av_dict_set(&s->metadata, "encoder", LIBAVFORMAT_IDENT, 0);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (s->oformat->write_header) {
 | 
					    if (options) {
 | 
				
			||||||
        ret = s->oformat->write_header(s);
 | 
					         av_dict_free(options);
 | 
				
			||||||
        if (ret >= 0 && s->pb && s->pb->error < 0)
 | 
					         *options = tmp;
 | 
				
			||||||
            ret = s->pb->error;
 | 
					 | 
				
			||||||
        if (ret < 0)
 | 
					 | 
				
			||||||
            goto fail;
 | 
					 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					fail:
 | 
				
			||||||
 | 
					    av_dict_free(&tmp);
 | 
				
			||||||
 | 
					    return ret;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int init_pts(AVFormatContext *s)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int i;
 | 
				
			||||||
 | 
					    AVStream *st;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    /* init PTS generation */
 | 
					    /* init PTS generation */
 | 
				
			||||||
    for (i = 0; i < s->nb_streams; i++) {
 | 
					    for (i = 0; i < s->nb_streams; i++) {
 | 
				
			||||||
        int64_t den = AV_NOPTS_VALUE;
 | 
					        int64_t den = AV_NOPTS_VALUE;
 | 
				
			||||||
@@ -341,22 +351,35 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options)
 | 
				
			|||||||
            break;
 | 
					            break;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        if (den != AV_NOPTS_VALUE) {
 | 
					        if (den != AV_NOPTS_VALUE) {
 | 
				
			||||||
            if (den <= 0) {
 | 
					            if (den <= 0)
 | 
				
			||||||
                ret = AVERROR_INVALIDDATA;
 | 
					                return AVERROR_INVALIDDATA;
 | 
				
			||||||
                goto fail;
 | 
					
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            frac_init(&st->pts, 0, 0, den);
 | 
					            frac_init(&st->pts, 0, 0, den);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (options) {
 | 
					 | 
				
			||||||
        av_dict_free(options);
 | 
					 | 
				
			||||||
        *options = tmp;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return 0;
 | 
					    return 0;
 | 
				
			||||||
fail:
 | 
					}
 | 
				
			||||||
    av_dict_free(&tmp);
 | 
					
 | 
				
			||||||
    return ret;
 | 
					int avformat_write_header(AVFormatContext *s, AVDictionary **options)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    int ret = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (ret = init_muxer(s, options))
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (s->oformat->write_header) {
 | 
				
			||||||
 | 
					        ret = s->oformat->write_header(s);
 | 
				
			||||||
 | 
					        if (ret >= 0 && s->pb && s->pb->error < 0)
 | 
				
			||||||
 | 
					            ret = s->pb->error;
 | 
				
			||||||
 | 
					        if (ret < 0)
 | 
				
			||||||
 | 
					            return ret;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if ((ret = init_pts(s) < 0))
 | 
				
			||||||
 | 
					        return ret;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//FIXME merge with compute_pkt_fields
 | 
					//FIXME merge with compute_pkt_fields
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user