Commit 27fbe31c authored by Michael Niedermayer's avatar Michael Niedermayer

Merge remote-tracking branch 'qatar/master'

* qatar/master:
  Revert "avconv: use stream copy by default when possible."
  avconv: print stream copy information.
  avconv: use stream copy by default when possible.
  matroskaenc: vertical alignment.
  matroskaenc: implement query_codec()
  lavf: add avformat_query_codec().
  lavc: add avcodec_get_type() for mapping codec_id -> type.
  flvenc: use int64_t to store offsets
  avconv: don't segfault on 0 input files.
  Do not write ID3v1 tags by default
  mpegts: log into an AVFormatContext rather than MpegTSContext.

Conflicts:
	doc/APIchanges
	libavcodec/version.h
	libavformat/avformat.h
	libavformat/mp3enc.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents d071df88 6cd9d0f7
......@@ -2280,6 +2280,8 @@ static int transcode(AVFormatContext **output_files,
fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index,
ost->sync_ist->st->index);
if (ost->st->stream_copy)
fprintf(stderr, " (copy)");
fprintf(stderr, "\n");
}
}
......@@ -3804,7 +3806,7 @@ static int opt_output_file(const char *opt, const char *filename)
}
/* copy global metadata by default */
if (metadata_global_autocopy)
if (metadata_global_autocopy && nb_input_files)
av_dict_copy(&oc->metadata, input_files[0].ctx->metadata,
AV_DICT_DONT_OVERWRITE);
if (metadata_streams_autocopy)
......
......@@ -16,6 +16,12 @@ API changes, most recent first:
2011-08-14 - xxxxxx - lavu 52.12.0
Add av_fifo_peek2(), deprecate av_fifo_peek().
2011-08-xx - xxxxxxx - lavf 53.4.0
Add avformat_query_codec().
2011-08-xx - xxxxxxx - lavc 53.8.0
Add avcodec_get_type().
2011-08-06 - 2f63440 - lavf 53.4.0
Add error_recognition to AVFormatContext.
......
......@@ -212,6 +212,7 @@ enum CodecID {
CODEC_ID_G2M,
/* various PCM "codecs" */
CODEC_ID_FIRST_AUDIO = 0x10000, ///< A dummy id pointing at the start of audio codecs
CODEC_ID_PCM_S16LE= 0x10000,
CODEC_ID_PCM_S16BE,
CODEC_ID_PCM_U16LE,
......@@ -343,6 +344,7 @@ enum CodecID {
CODEC_ID_CELT,
/* subtitle codecs */
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
CODEC_ID_DVD_SUBTITLE= 0x17000,
CODEC_ID_DVB_SUBTITLE,
CODEC_ID_TEXT, ///< raw UTF-8 text
......@@ -355,6 +357,7 @@ enum CodecID {
CODEC_ID_MICRODVD,
/* other specific kind of codecs (generally used for attachments) */
CODEC_ID_FIRST_UNKNOWN = 0x18000, ///< A dummy ID pointing at the start of various fake codecs.
CODEC_ID_TTF= 0x18000,
CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it
......@@ -4342,4 +4345,9 @@ enum AVLockOp {
*/
int av_lockmgr_register(int (*cb)(void **mutex, enum AVLockOp op));
/**
* Get the type of the given codec.
*/
enum AVMediaType avcodec_get_type(enum CodecID codec_id);
#endif /* AVCODEC_AVCODEC_H */
......@@ -1380,3 +1380,17 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count)
return ff_thread_init(s);
}
#endif
enum AVMediaType avcodec_get_type(enum CodecID codec_id)
{
if (codec_id <= CODEC_ID_NONE)
return AVMEDIA_TYPE_UNKNOWN;
else if (codec_id < CODEC_ID_FIRST_AUDIO)
return AVMEDIA_TYPE_VIDEO;
else if (codec_id < CODEC_ID_FIRST_SUBTITLE)
return AVMEDIA_TYPE_AUDIO;
else if (codec_id < CODEC_ID_FIRST_UNKNOWN)
return AVMEDIA_TYPE_SUBTITLE;
return AVMEDIA_TYPE_UNKNOWN;
}
......@@ -21,7 +21,7 @@
#define AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 10
#define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
......
......@@ -324,6 +324,14 @@ typedef struct AVOutputFormat {
const AVClass *priv_class; ///< AVClass for the private context
/**
* Test if the given codec can be stored in this container.
*
* @return 1 if the codec is supported, 0 if it is not.
* A negative number if unknown.
*/
int (*query_codec)(enum CodecID id, int std_compliance);
void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
int64_t *dts, int64_t *wall);
......@@ -1690,4 +1698,14 @@ attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char
*/
int av_match_ext(const char *filename, const char *extensions);
/**
* Test if the given container can store a codec.
*
* @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
*
* @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
* A negative number if this information is not available.
*/
int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance);
#endif /* AVFORMAT_AVFORMAT_H */
......@@ -180,7 +180,7 @@ static int flv_write_header(AVFormatContext *s)
AVCodecContext *audio_enc = NULL, *video_enc = NULL;
int i;
double framerate = 0.0;
int metadata_size_pos, data_size;
int64_t metadata_size_pos, data_size;
AVDictionaryEntry *tag = NULL;
for(i=0; i<s->nb_streams; i++){
......
......@@ -1198,6 +1198,22 @@ static int mkv_write_trailer(AVFormatContext *s)
return 0;
}
static int mkv_query_codec(enum CodecID codec_id, int std_compliance)
{
int i;
for (i = 0; ff_mkv_codec_tags[i].id != CODEC_ID_NONE; i++)
if (ff_mkv_codec_tags[i].id == codec_id)
return 1;
if (std_compliance < FF_COMPLIANCE_NORMAL) { // mkv theoretically supports any
enum AVMediaType type = avcodec_get_type(codec_id); // video/audio through VFW/ACM
if (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)
return 1;
}
return 0;
}
#if CONFIG_MATROSKA_MUXER
AVOutputFormat ff_matroska_muxer = {
.name = "matroska",
......@@ -1210,9 +1226,10 @@ AVOutputFormat ff_matroska_muxer = {
.write_header = mkv_write_header,
.write_packet = mkv_write_packet,
.write_trailer = mkv_write_trailer,
.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
.codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
.subtitle_codec = CODEC_ID_SSA,
.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
.codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
.subtitle_codec = CODEC_ID_SSA,
.query_codec = mkv_query_codec,
};
#endif
......
......@@ -141,6 +141,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
typedef struct MP3Context {
const AVClass *class;
int id3v2_version;
int write_id3v1;
int64_t frames_offset;
int32_t frames;
int32_t size;
......@@ -156,7 +157,7 @@ static int mp2_write_trailer(struct AVFormatContext *s)
MP3Context *mp3 = s->priv_data;
/* write the id3v1 tag */
if (id3v1_create_tag(s, buf) > 0) {
if (mp3 && mp3->write_id3v1 && id3v1_create_tag(s, buf) > 0) {
avio_write(s->pb, buf, ID3v1_TAG_SIZE);
}
......@@ -190,6 +191,8 @@ AVOutputFormat ff_mp2_muxer = {
static const AVOption options[] = {
{ "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.",
offsetof(MP3Context, id3v2_version), FF_OPT_TYPE_INT, {.dbl = 4}, 3, 4, AV_OPT_FLAG_ENCODING_PARAM},
{ "write_id3v1", "Enable ID3v1 writing. ID3v1 tags are written in UTF-8 which may not be supported by most software.",
offsetof(MP3Context, write_id3v1), FF_OPT_TYPE_INT, {.dbl = 0}, 0, 1, AV_OPT_FLAG_ENCODING_PARAM},
{ NULL },
};
......
......@@ -4035,3 +4035,17 @@ int64_t ff_iso8601_to_unix_time(const char *datestr)
return 0;
#endif
}
int avformat_query_codec(AVOutputFormat *ofmt, enum CodecID codec_id, int std_compliance)
{
if (ofmt) {
if (ofmt->query_codec)
return ofmt->query_codec(codec_id, std_compliance);
else if (ofmt->codec_tag)
return !!av_codec_get_tag(ofmt->codec_tag, codec_id);
else if (codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec ||
codec_id == ofmt->subtitle_codec)
return 1;
}
return AVERROR_PATCHWELCOME;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment