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: Michael Niedermayer <michaelni@gmx.at>
pull/2/head
Michael Niedermayer 13 years ago
commit 27fbe31c92
  1. 4
      avconv.c
  2. 6
      doc/APIchanges
  3. 8
      libavcodec/avcodec.h
  4. 14
      libavcodec/utils.c
  5. 2
      libavcodec/version.h
  6. 18
      libavformat/avformat.h
  7. 2
      libavformat/flvenc.c
  8. 23
      libavformat/matroskaenc.c
  9. 5
      libavformat/mp3enc.c
  10. 14
      libavformat/utils.c

@ -2280,6 +2280,8 @@ static int transcode(AVFormatContext **output_files,
fprintf(stderr, " [sync #%d.%d]", fprintf(stderr, " [sync #%d.%d]",
ost->sync_ist->file_index, ost->sync_ist->file_index,
ost->sync_ist->st->index); ost->sync_ist->st->index);
if (ost->st->stream_copy)
fprintf(stderr, " (copy)");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
} }
} }
@ -3804,7 +3806,7 @@ static int opt_output_file(const char *opt, const char *filename)
} }
/* copy global metadata by default */ /* 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_copy(&oc->metadata, input_files[0].ctx->metadata,
AV_DICT_DONT_OVERWRITE); AV_DICT_DONT_OVERWRITE);
if (metadata_streams_autocopy) if (metadata_streams_autocopy)

@ -16,6 +16,12 @@ API changes, most recent first:
2011-08-14 - xxxxxx - lavu 52.12.0 2011-08-14 - xxxxxx - lavu 52.12.0
Add av_fifo_peek2(), deprecate av_fifo_peek(). 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 2011-08-06 - 2f63440 - lavf 53.4.0
Add error_recognition to AVFormatContext. Add error_recognition to AVFormatContext.

@ -212,6 +212,7 @@ enum CodecID {
CODEC_ID_G2M, CODEC_ID_G2M,
/* various PCM "codecs" */ /* 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_S16LE= 0x10000,
CODEC_ID_PCM_S16BE, CODEC_ID_PCM_S16BE,
CODEC_ID_PCM_U16LE, CODEC_ID_PCM_U16LE,
@ -343,6 +344,7 @@ enum CodecID {
CODEC_ID_CELT, CODEC_ID_CELT,
/* subtitle codecs */ /* subtitle codecs */
CODEC_ID_FIRST_SUBTITLE = 0x17000, ///< A dummy ID pointing at the start of subtitle codecs.
CODEC_ID_DVD_SUBTITLE= 0x17000, CODEC_ID_DVD_SUBTITLE= 0x17000,
CODEC_ID_DVB_SUBTITLE, CODEC_ID_DVB_SUBTITLE,
CODEC_ID_TEXT, ///< raw UTF-8 text CODEC_ID_TEXT, ///< raw UTF-8 text
@ -355,6 +357,7 @@ enum CodecID {
CODEC_ID_MICRODVD, CODEC_ID_MICRODVD,
/* other specific kind of codecs (generally used for attachments) */ /* 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_TTF= 0x18000,
CODEC_ID_PROBE= 0x19000, ///< codec_id is not known (like CODEC_ID_NONE) but lavf should attempt to identify it 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)); 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 */ #endif /* AVCODEC_AVCODEC_H */

@ -1380,3 +1380,17 @@ int avcodec_thread_init(AVCodecContext *s, int thread_count)
return ff_thread_init(s); return ff_thread_init(s);
} }
#endif #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 AVCODEC_VERSION_H
#define LIBAVCODEC_VERSION_MAJOR 53 #define LIBAVCODEC_VERSION_MAJOR 53
#define LIBAVCODEC_VERSION_MINOR 10 #define LIBAVCODEC_VERSION_MINOR 11
#define LIBAVCODEC_VERSION_MICRO 0 #define LIBAVCODEC_VERSION_MICRO 0
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ #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 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, void (*get_output_timestamp)(struct AVFormatContext *s, int stream,
int64_t *dts, int64_t *wall); 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); 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 */ #endif /* AVFORMAT_AVFORMAT_H */

@ -180,7 +180,7 @@ static int flv_write_header(AVFormatContext *s)
AVCodecContext *audio_enc = NULL, *video_enc = NULL; AVCodecContext *audio_enc = NULL, *video_enc = NULL;
int i; int i;
double framerate = 0.0; double framerate = 0.0;
int metadata_size_pos, data_size; int64_t metadata_size_pos, data_size;
AVDictionaryEntry *tag = NULL; AVDictionaryEntry *tag = NULL;
for(i=0; i<s->nb_streams; i++){ for(i=0; i<s->nb_streams; i++){

@ -1198,6 +1198,22 @@ static int mkv_write_trailer(AVFormatContext *s)
return 0; 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 #if CONFIG_MATROSKA_MUXER
AVOutputFormat ff_matroska_muxer = { AVOutputFormat ff_matroska_muxer = {
.name = "matroska", .name = "matroska",
@ -1210,9 +1226,10 @@ AVOutputFormat ff_matroska_muxer = {
.write_header = mkv_write_header, .write_header = mkv_write_header,
.write_packet = mkv_write_packet, .write_packet = mkv_write_packet,
.write_trailer = mkv_write_trailer, .write_trailer = mkv_write_trailer,
.flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS, .flags = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
.codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0}, .codec_tag = (const AVCodecTag* const []){ff_codec_bmp_tags, ff_codec_wav_tags, 0},
.subtitle_codec = CODEC_ID_SSA, .subtitle_codec = CODEC_ID_SSA,
.query_codec = mkv_query_codec,
}; };
#endif #endif

@ -141,6 +141,7 @@ static int id3v2_put_ttag(AVFormatContext *s, const char *str1, const char *str2
typedef struct MP3Context { typedef struct MP3Context {
const AVClass *class; const AVClass *class;
int id3v2_version; int id3v2_version;
int write_id3v1;
int64_t frames_offset; int64_t frames_offset;
int32_t frames; int32_t frames;
int32_t size; int32_t size;
@ -156,7 +157,7 @@ static int mp2_write_trailer(struct AVFormatContext *s)
MP3Context *mp3 = s->priv_data; MP3Context *mp3 = s->priv_data;
/* write the id3v1 tag */ /* 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); avio_write(s->pb, buf, ID3v1_TAG_SIZE);
} }
@ -190,6 +191,8 @@ AVOutputFormat ff_mp2_muxer = {
static const AVOption options[] = { static const AVOption options[] = {
{ "id3v2_version", "Select ID3v2 version to write. Currently 3 and 4 are supported.", { "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}, 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 }, { NULL },
}; };

@ -4035,3 +4035,17 @@ int64_t ff_iso8601_to_unix_time(const char *datestr)
return 0; return 0;
#endif #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;
}

Loading…
Cancel
Save