[libav-commits] libavcodec: set AVFrame colorspace fields on decoding

2014-06-01 Thread wm4
Module: libav
Branch: master
Commit: eb800f120d2d42590fde2302fe828c847e41e773

Author:wm4 nfx...@googlemail.com
Committer: Anton Khirnov an...@khirnov.net
Date:  Fri May 30 22:14:22 2014 +0200

libavcodec: set AVFrame colorspace fields on decoding

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavcodec/utils.c |7 +++
 1 file changed, 7 insertions(+)

diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index cb456d5..dff8419 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -580,6 +580,13 @@ int ff_decode_frame_props(AVCodecContext *avctx, AVFrame 
*frame)
 int size;
 AVFrameSideData *frame_sd;
 
+#if FF_API_AVFRAME_COLORSPACE
+frame-color_primaries = avctx-color_primaries;
+frame-color_trc   = avctx-color_trc;
+frame-colorspace  = avctx-colorspace;
+frame-color_range = avctx-color_range;
+frame-chroma_location = avctx-chroma_sample_location;
+#endif
 
 frame-reordered_opaque = avctx-reordered_opaque;
 if (!pkt) {

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] lavc: add an option to enable side data-only packets during encoding

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 0957b274e312e985d69cb490bee2a7ff820acaa6

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Apr 29 15:06:45 2014 +0200

lavc: add an option to enable side data-only packets during encoding

Some encoders (e.g. flac) need to send side data when there is no more
data to be output. This enables them to output a packet with no data in
it, only side data.

---

 doc/APIchanges |5 +
 libavcodec/avcodec.h   |   15 +++
 libavcodec/options_table.h |1 +
 libavcodec/version.h   |2 +-
 4 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/doc/APIchanges b/doc/APIchanges
index 367f8e1..952ee51 100644
--- a/doc/APIchanges
+++ b/doc/APIchanges
@@ -13,6 +13,11 @@ libavutil: 2013-12-xx
 
 API changes, most recent first:
 
+2014-04-xx - xxx - lavc 55.54.0 - avcodec.h
+  Add AVCodecContext.side_data_only_packets to allow encoders to output packets
+  with only side data. This option may become mandatory in the future, so all
+  users are recommended to update their code and enable this option.
+
 2014-xx-xx - xxx - lavu 53.16.0 - frame.h, pixfmt.h
   Move all color-related enums (AVColorPrimaries, AVColorSpace, AVColorRange,
   AVColorTransferCharacteristic, and AVChromaLocation) inside lavu.
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 4310419..0396ea5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -2730,6 +2730,21 @@ typedef struct AVCodecContext {
  * - decoding: unused.
  */
 uint64_t vbv_delay;
+
+/**
+ * Encoding only. Allow encoders to output packets that do not contain any
+ * encoded data, only side data.
+ *
+ * Some encoders need to output such packets, e.g. to update some stream
+ * parameters at the end of encoding.
+ *
+ * All callers are strongly recommended to set this option to 1 and update
+ * their code to deal with such packets, since this behaviour may become
+ * always enabled in the future (then this option will be deprecated and
+ * later removed). To avoid ABI issues when this happens, the callers 
should
+ * use AVOptions to set this field.
+ */
+int side_data_only_packets;
 } AVCodecContext;
 
 /**
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index 6825e62..f018b21 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -399,6 +399,7 @@ static const AVOption avcodec_options[] = {
 {fltp, 32-bit float planar,   0, AV_OPT_TYPE_CONST, {.i64 = 
AV_SAMPLE_FMT_FLTP }, INT_MIN, INT_MAX, A|D, request_sample_fmt},
 {dblp, 64-bit double planar,  0, AV_OPT_TYPE_CONST, {.i64 = 
AV_SAMPLE_FMT_DBLP }, INT_MIN, INT_MAX, A|D, request_sample_fmt},
 {refcounted_frames, NULL, OFFSET(refcounted_frames), AV_OPT_TYPE_INT, {.i64 
= 0}, 0, 1, A|V|D },
+{side_data_only_packets, NULL, OFFSET(side_data_only_packets), 
AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, A|V|E },
 {NULL},
 };
 
diff --git a/libavcodec/version.h b/libavcodec/version.h
index d72f8ed..c02540a 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
 #include libavutil/version.h
 
 #define LIBAVCODEC_VERSION_MAJOR 55
-#define LIBAVCODEC_VERSION_MINOR 53
+#define LIBAVCODEC_VERSION_MINOR 54
 #define LIBAVCODEC_VERSION_MICRO  0
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] flac muxer: accept only STREAMINFO extradata

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 0097cbea695e534fce39958ccd103af2fbf65831

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Mon May 26 15:51:22 2014 +0200

flac muxer: accept only STREAMINFO extradata

The other format (full flac header blocks) should not be exported by any
demuxers anymore.

This allows to drop an avpriv_ function and also simplify the following
commits.

---

 libavformat/flacenc_header.c |   11 +--
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c
index 0d19b3c..a6e2b59 100644
--- a/libavformat/flacenc_header.c
+++ b/libavformat/flacenc_header.c
@@ -22,7 +22,7 @@
 #include libavutil/channel_layout.h
 
 #include libavcodec/flac.h
-#include libavcodec/bytestream.h
+
 #include avformat.h
 #include flacenc.h
 
@@ -32,18 +32,17 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext 
*codec,
 uint8_t header[8] = {
 0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22
 };
-uint8_t *streaminfo;
-enum FLACExtradataFormat format;
 
 header[4] = last_block ? 0x80 : 0x00;
-if (!avpriv_flac_is_extradata_valid(codec, format, streaminfo))
-return -1;
+
+if (codec-extradata_size  FLAC_STREAMINFO_SIZE)
+return AVERROR_INVALIDDATA;
 
 /* write fLaC stream marker and first metadata block header */
 avio_write(pb, header, 8);
 
 /* write STREAMINFO */
-avio_write(pb, streaminfo, FLAC_STREAMINFO_SIZE);
+avio_write(pb, codec-extradata, FLAC_STREAMINFO_SIZE);
 
 return 0;
 }

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] avconv: do not use the stream codec context for encoding

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 383136264ef40452efd86cafb2d7221cd3830b3d

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Sat Apr  5 08:48:24 2014 +0200

avconv: do not use the stream codec context for encoding

---

 avconv.c|   91 ++-
 avconv.h|1 +
 avconv_filter.c |8 ++---
 avconv_opt.c|   27 +
 4 files changed, 69 insertions(+), 58 deletions(-)

diff --git a/avconv.c b/avconv.c
index 30b85cc..b167ff6 100644
--- a/avconv.c
+++ b/avconv.c
@@ -191,6 +191,8 @@ static void avconv_cleanup(int ret)
 av_freep(ost-avfilter);
 av_freep(ost-logfile_prefix);
 
+avcodec_free_context(ost-enc_ctx);
+
 av_freep(output_streams[i]);
 }
 for (i = 0; i  nb_input_files; i++) {
@@ -316,7 +318,7 @@ static void update_sample_fmt(AVCodecContext *dec, AVCodec 
*dec_codec,
 static void write_frame(AVFormatContext *s, AVPacket *pkt, OutputStream *ost)
 {
 AVBitStreamFilterContext *bsfc = ost-bitstream_filters;
-AVCodecContext  *avctx = ost-st-codec;
+AVCodecContext  *avctx = ost-enc_ctx;
 int ret;
 
 /*
@@ -394,7 +396,7 @@ static int check_recording_time(OutputStream *ost)
 OutputFile *of = output_files[ost-file_index];
 
 if (of-recording_time != INT64_MAX 
-av_compare_ts(ost-sync_opts - ost-first_pts, 
ost-st-codec-time_base, of-recording_time,
+av_compare_ts(ost-sync_opts - ost-first_pts, 
ost-enc_ctx-time_base, of-recording_time,
   AV_TIME_BASE_Q) = 0) {
 ost-finished = 1;
 return 0;
@@ -405,7 +407,7 @@ static int check_recording_time(OutputStream *ost)
 static void do_audio_out(AVFormatContext *s, OutputStream *ost,
  AVFrame *frame)
 {
-AVCodecContext *enc = ost-st-codec;
+AVCodecContext *enc = ost-enc_ctx;
 AVPacket pkt;
 int got_packet = 0;
 
@@ -456,7 +458,7 @@ static void do_subtitle_out(AVFormatContext *s,
 return;
 }
 
-enc = ost-st-codec;
+enc = ost-enc_ctx;
 
 if (!subtitle_out) {
 subtitle_out = av_malloc(subtitle_out_max_size);
@@ -513,7 +515,7 @@ static void do_video_out(AVFormatContext *s,
 {
 int ret, format_video_sync;
 AVPacket pkt;
-AVCodecContext *enc = ost-st-codec;
+AVCodecContext *enc = ost-enc_ctx;
 
 *frame_size = 0;
 
@@ -563,11 +565,11 @@ static void do_video_out(AVFormatContext *s,
 } else {
 int got_packet;
 
-if (ost-st-codec-flags  
(CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) 
+if (enc-flags  (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME) 

 ost-top_field_first = 0)
 in_picture-top_field_first = !!ost-top_field_first;
 
-in_picture-quality = ost-st-codec-global_quality;
+in_picture-quality = enc-global_quality;
 if (!enc-me_threshold)
 in_picture-pict_type = 0;
 if (ost-forced_kf_index  ost-forced_kf_count 
@@ -628,7 +630,7 @@ static void do_video_stats(OutputStream *ost, int 
frame_size)
 }
 }
 
-enc = ost-st-codec;
+enc = ost-enc_ctx;
 if (enc-codec_type == AVMEDIA_TYPE_VIDEO) {
 frame_number = ost-frame_number;
 fprintf(vstats_file, frame= %5d q= %2.1f , frame_number, 
enc-coded_frame-quality / (float)FF_QP2LAMBDA);
@@ -666,7 +668,7 @@ static int poll_filter(OutputStream *ost)
 if (ost-enc-type == AVMEDIA_TYPE_AUDIO 
 !(ost-enc-capabilities  CODEC_CAP_VARIABLE_FRAME_SIZE))
 ret = av_buffersink_get_samples(ost-filter-filter, filtered_frame,
- ost-st-codec-frame_size);
+ ost-enc_ctx-frame_size);
 else
 ret = av_buffersink_get_frame(ost-filter-filter, filtered_frame);
 
@@ -677,16 +679,16 @@ static int poll_filter(OutputStream *ost)
 int64_t start_time = (of-start_time == AV_NOPTS_VALUE) ? 0 : 
of-start_time;
 filtered_frame-pts = av_rescale_q(filtered_frame-pts,

ost-filter-filter-inputs[0]-time_base,
-   ost-st-codec-time_base) -
+   ost-enc_ctx-time_base) -
   av_rescale_q(start_time,
AV_TIME_BASE_Q,
-   ost-st-codec-time_base);
+   ost-enc_ctx-time_base);
 }
 
 switch (ost-filter-filter-inputs[0]-type) {
 case AVMEDIA_TYPE_VIDEO:
 if (!ost-frame_aspect_ratio)
-ost-st-codec-sample_aspect_ratio = 
filtered_frame-sample_aspect_ratio;
+ost-enc_ctx-sample_aspect_ratio = 
filtered_frame-sample_aspect_ratio;
 
 do_video_out(of-ctx, ost, filtered_frame, frame_size);
 if (vstats_filename  frame_size)
@@ -728,7 +730,7 @@ 

[libav-commits] flacenc: send final extradata in packet side data

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: ed39cda02923316b6710c1bcc34d3445370be5b4

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Tue Apr 29 15:11:30 2014 +0200

flacenc: send final extradata in packet side data

---

 libavcodec/flacenc.c |   20 
 1 file changed, 20 insertions(+)

diff --git a/libavcodec/flacenc.c b/libavcodec/flacenc.c
index 58e86be..9138b99 100644
--- a/libavcodec/flacenc.c
+++ b/libavcodec/flacenc.c
@@ -114,6 +114,9 @@ typedef struct FlacEncodeContext {
 unsigned int md5_buffer_size;
 DSPContext dsp;
 FLACDSPContext flac_dsp;
+
+int flushed;
+int64_t next_pts;
 } FlacEncodeContext;
 
 
@@ -1212,6 +1215,20 @@ static int flac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 s-max_framesize = s-max_encoded_framesize;
 av_md5_final(s-md5ctx, s-md5sum);
 write_streaminfo(s, avctx-extradata);
+
+if (avctx-side_data_only_packets  !s-flushed) {
+uint8_t *side_data = av_packet_new_side_data(avpkt, 
AV_PKT_DATA_NEW_EXTRADATA,
+ 
avctx-extradata_size);
+if (!side_data)
+return AVERROR(ENOMEM);
+memcpy(side_data, avctx-extradata, avctx-extradata_size);
+
+avpkt-pts = s-next_pts;
+
+*got_packet_ptr = 1;
+s-flushed = 1;
+}
+
 return 0;
 }
 
@@ -1264,6 +1281,9 @@ static int flac_encode_frame(AVCodecContext *avctx, 
AVPacket *avpkt,
 avpkt-pts  = frame-pts;
 avpkt-duration = ff_samples_to_time_base(avctx, frame-nb_samples);
 avpkt-size = out_bytes;
+
+s-next_pts = avpkt-pts + avpkt-duration;
+
 *got_packet_ptr = 1;
 return 0;
 }

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] flac muxer: support reading updated extradata from side data

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: e19d48dfce52f1417f7f06143b96fed00cbcdc52

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Mon May 26 22:14:14 2014 +0200

flac muxer: support reading updated extradata from side data

---

 libavformat/flacenc.c|   37 +
 libavformat/flacenc.h|4 ++--
 libavformat/flacenc_header.c |8 
 libavformat/matroskaenc.c|3 ++-
 4 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 0365764..a686826 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -31,6 +31,9 @@
 typedef struct FlacMuxerContext {
 const AVClass *class;
 int write_header;
+
+/* updated streaminfo sent by the encoder at the end */
+uint8_t *streaminfo;
 } FlacMuxerContext;
 
 static int flac_write_block_padding(AVIOContext *pb, unsigned int 
n_padding_bytes,
@@ -80,7 +83,8 @@ static int flac_write_header(struct AVFormatContext *s)
 if (!c-write_header)
 return 0;
 
-ret = ff_flac_write_header(s-pb, codec, 0);
+ret = ff_flac_write_header(s-pb, codec-extradata,
+   codec-extradata_size, 0);
 if (ret)
 return ret;
 
@@ -118,17 +122,14 @@ static int flac_write_header(struct AVFormatContext *s)
 static int flac_write_trailer(struct AVFormatContext *s)
 {
 AVIOContext *pb = s-pb;
-uint8_t *streaminfo;
-enum FLACExtradataFormat format;
 int64_t file_size;
 FlacMuxerContext *c = s-priv_data;
+uint8_t *streaminfo = c-streaminfo ? c-streaminfo :
+  s-streams[0]-codec-extradata;
 
-if (!c-write_header)
+if (!c-write_header || !streaminfo)
 return 0;
 
-if (!avpriv_flac_is_extradata_valid(s-streams[0]-codec, format, 
streaminfo))
-return -1;
-
 if (pb-seekable) {
 /* rewrite the STREAMINFO header block data */
 file_size = avio_tell(pb);
@@ -139,12 +140,32 @@ static int flac_write_trailer(struct AVFormatContext *s)
 } else {
 av_log(s, AV_LOG_WARNING, unable to rewrite FLAC header.\n);
 }
+
+av_freep(c-streaminfo);
+
 return 0;
 }
 
 static int flac_write_packet(struct AVFormatContext *s, AVPacket *pkt)
 {
-avio_write(s-pb, pkt-data, pkt-size);
+FlacMuxerContext *c = s-priv_data;
+uint8_t *streaminfo;
+int streaminfo_size;
+
+/* check for updated streaminfo */
+streaminfo = av_packet_get_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
+ streaminfo_size);
+if (streaminfo  streaminfo_size == FLAC_STREAMINFO_SIZE) {
+av_freep(c-streaminfo);
+
+c-streaminfo = av_malloc(FLAC_STREAMINFO_SIZE);
+if (!c-streaminfo)
+return AVERROR(ENOMEM);
+memcpy(c-streaminfo, streaminfo, FLAC_STREAMINFO_SIZE);
+}
+
+if (pkt-size)
+avio_write(s-pb, pkt-data, pkt-size);
 return 0;
 }
 
diff --git a/libavformat/flacenc.h b/libavformat/flacenc.h
index 3964ce4..54dd833 100644
--- a/libavformat/flacenc.h
+++ b/libavformat/flacenc.h
@@ -26,8 +26,8 @@
 #include libavcodec/bytestream.h
 #include avformat.h
 
-int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
- int last_block);
+int ff_flac_write_header(AVIOContext *pb, uint8_t *extradata,
+ int extradata_size, int last_block);
 
 int ff_flac_is_native_layout(uint64_t channel_layout);
 
diff --git a/libavformat/flacenc_header.c b/libavformat/flacenc_header.c
index a6e2b59..4f9bb20 100644
--- a/libavformat/flacenc_header.c
+++ b/libavformat/flacenc_header.c
@@ -26,8 +26,8 @@
 #include avformat.h
 #include flacenc.h
 
-int ff_flac_write_header(AVIOContext *pb, AVCodecContext *codec,
- int last_block)
+int ff_flac_write_header(AVIOContext *pb, uint8_t *extradata,
+ int extradata_size, int last_block)
 {
 uint8_t header[8] = {
 0x66, 0x4C, 0x61, 0x43, 0x00, 0x00, 0x00, 0x22
@@ -35,14 +35,14 @@ int ff_flac_write_header(AVIOContext *pb, AVCodecContext 
*codec,
 
 header[4] = last_block ? 0x80 : 0x00;
 
-if (codec-extradata_size  FLAC_STREAMINFO_SIZE)
+if (extradata_size  FLAC_STREAMINFO_SIZE)
 return AVERROR_INVALIDDATA;
 
 /* write fLaC stream marker and first metadata block header */
 avio_write(pb, header, 8);
 
 /* write STREAMINFO */
-avio_write(pb, codec-extradata, FLAC_STREAMINFO_SIZE);
+avio_write(pb, extradata, FLAC_STREAMINFO_SIZE);
 
 return 0;
 }
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index 919cdfd..7d3050e 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -477,7 +477,8 @@ static int put_flac_codecpriv(AVFormatContext *s,
 int write_comment = (codec-channel_layout 
  !(codec-channel_layout  ~0x3ULL) 
  

[libav-commits] avconv: do not use the stream codec context for decoding

2014-06-01 Thread Anton Khirnov
Module: libav
Branch: master
Commit: 41776ba9c0ebbb71394cefdf7dd1b243e6c852d5

Author:Anton Khirnov an...@khirnov.net
Committer: Anton Khirnov an...@khirnov.net
Date:  Sat Apr  5 08:48:24 2014 +0200

avconv: do not use the stream codec context for decoding

---

 avconv.c|   66 ---
 avconv.h|1 +
 avconv_filter.c |   18 +++
 avconv_opt.c|   28 ---
 4 files changed, 64 insertions(+), 49 deletions(-)

diff --git a/avconv.c b/avconv.c
index 2cee09b..30b85cc 100644
--- a/avconv.c
+++ b/avconv.c
@@ -206,6 +206,8 @@ static void avconv_cleanup(int ret)
 av_freep(ist-filters);
 av_freep(ist-hwaccel_device);
 
+avcodec_free_context(ist-dec_ctx);
+
 av_freep(input_streams[i]);
 }
 
@@ -800,7 +802,7 @@ static void print_final_stats(int64_t total_size)
 
 for (j = 0; j  f-nb_streams; j++) {
 InputStream *ist = input_streams[f-ist_index + j];
-enum AVMediaType type = ist-st-codec-codec_type;
+enum AVMediaType type = ist-dec_ctx-codec_type;
 
 total_size+= ist-data_size;
 total_packets += ist-nb_packets;
@@ -1139,7 +1141,7 @@ static void do_streamcopy(InputStream *ist, OutputStream 
*ost, const AVPacket *p
 
 int guess_input_channel_layout(InputStream *ist)
 {
-AVCodecContext *dec = ist-st-codec;
+AVCodecContext *dec = ist-dec_ctx;
 
 if (!dec-channel_layout) {
 char layout_name[256];
@@ -1158,7 +1160,7 @@ int guess_input_channel_layout(InputStream *ist)
 static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output)
 {
 AVFrame *decoded_frame, *f;
-AVCodecContext *avctx = ist-st-codec;
+AVCodecContext *avctx = ist-dec_ctx;
 int i, ret, err = 0, resample_changed;
 
 if (!ist-decoded_frame  !(ist-decoded_frame = av_frame_alloc()))
@@ -1231,7 +1233,7 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, 
int *got_output)
 if (decoded_frame-pts != AV_NOPTS_VALUE)
 decoded_frame-pts = av_rescale_q(decoded_frame-pts,
   ist-st-time_base,
-  (AVRational){1, 
ist-st-codec-sample_rate});
+  (AVRational){1, avctx-sample_rate});
 for (i = 0; i  ist-nb_filters; i++) {
 if (i  ist-nb_filters - 1) {
 f = ist-filter_frame;
@@ -1262,7 +1264,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output)
 return AVERROR(ENOMEM);
 decoded_frame = ist-decoded_frame;
 
-ret = avcodec_decode_video2(ist-st-codec,
+ret = avcodec_decode_video2(ist-dec_ctx,
 decoded_frame, got_output, pkt);
 if (!*got_output || ret  0) {
 if (!pkt-size) {
@@ -1275,7 +1277,7 @@ static int decode_video(InputStream *ist, AVPacket *pkt, 
int *got_output)
 ist-frames_decoded++;
 
 if (ist-hwaccel_retrieve_data  decoded_frame-format == 
ist-hwaccel_pix_fmt) {
-err = ist-hwaccel_retrieve_data(ist-st-codec, decoded_frame);
+err = ist-hwaccel_retrieve_data(ist-dec_ctx, decoded_frame);
 if (err  0)
 goto fail;
 }
@@ -1337,7 +1339,7 @@ fail:
 static int transcode_subtitles(InputStream *ist, AVPacket *pkt, int 
*got_output)
 {
 AVSubtitle subtitle;
-int i, ret = avcodec_decode_subtitle2(ist-st-codec,
+int i, ret = avcodec_decode_subtitle2(ist-dec_ctx,
   subtitle, got_output, pkt);
 if (ret  0)
 return ret;
@@ -1396,7 +1398,7 @@ static int output_packet(InputStream *ist, const AVPacket 
*pkt)
 ist-showed_multi_packet_warning = 1;
 }
 
-switch (ist-st-codec-codec_type) {
+switch (ist-dec_ctx-codec_type) {
 case AVMEDIA_TYPE_AUDIO:
 ret = decode_audio(ist, avpkt, got_output);
 break;
@@ -1407,10 +1409,10 @@ static int output_packet(InputStream *ist, const 
AVPacket *pkt)
 else if (ist-st-avg_frame_rate.num)
 ist-next_dts += av_rescale_q(1, 
av_inv_q(ist-st-avg_frame_rate),
   AV_TIME_BASE_Q);
-else if (ist-st-codec-time_base.num != 0) {
+else if (ist-dec_ctx-time_base.num != 0) {
 int ticks  = ist-st-parser ? 
ist-st-parser-repeat_pict + 1 :
-   
ist-st-codec-ticks_per_frame;
-ist-next_dts += av_rescale_q(ticks, 
ist-st-codec-time_base, AV_TIME_BASE_Q);
+   
ist-dec_ctx-ticks_per_frame;
+ist-next_dts += av_rescale_q(ticks, ist-dec_ctx-time_base, 
AV_TIME_BASE_Q);
 }
 break;
 case AVMEDIA_TYPE_SUBTITLE:
@@ -1435,17 +1437,17 @@ static int output_packet(InputStream *ist, const 
AVPacket *pkt)
 /* handle stream copy 

[libav-commits] matroskaenc: Allow VP9 and Opus in webm

2014-06-01 Thread Tudor Suciu
Module: libav
Branch: master
Commit: d2ef708c95ace2518deffe830a9c439aeb9edd5d

Author:Tudor Suciu tudor.su...@gmail.com
Committer: Anton Khirnov an...@khirnov.net
Date:  Sun Jun  2 17:49:24 2013 +0200

matroskaenc: Allow VP9 and Opus in webm

Bug-Id: 695

Signed-off-by: Anton Khirnov an...@khirnov.net

---

 libavformat/matroskaenc.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index f6af0f8..919cdfd 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -670,9 +670,11 @@ static int mkv_write_tracks(AVFormatContext *s)
 }
 
 if (mkv-mode == MODE_WEBM  !(codec-codec_id == AV_CODEC_ID_VP8 ||
+codec-codec_id == AV_CODEC_ID_VP9 ||
+codec-codec_id == AV_CODEC_ID_OPUS ||
 codec-codec_id == 
AV_CODEC_ID_VORBIS)) {
 av_log(s, AV_LOG_ERROR,
-   Only VP8 video and Vorbis audio are supported for 
WebM.\n);
+   Only VP8 or VP9 video and Vorbis or Opus audio are 
supported for WebM.\n);
 return AVERROR(EINVAL);
 }
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Decode both parts of Indeo4 IP frames

2014-06-01 Thread Dirk Ausserhaus
Module: libav
Branch: master
Commit: f76e3669bb350ca6df150244f3d28d7dc5599f01

Author:Dirk Ausserhaus dausserh...@gmail.com
Committer: Kostya Shishkov kostya.shish...@gmail.com
Date:  Thu May 29 13:30:37 2014 +0200

Decode both parts of Indeo4 IP frames

Signed-off-by: Kostya Shishkov kostya.shish...@gmail.com

---

 libavcodec/indeo4.c |4 
 libavcodec/ivi_common.c |   48 ++-
 libavcodec/ivi_common.h |3 +++
 3 files changed, 42 insertions(+), 13 deletions(-)

diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index ca81d62..3e97221 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -620,6 +620,10 @@ static av_cold int decode_init(AVCodecContext *avctx)
 ctx-switch_buffers   = switch_buffers;
 ctx-is_nonnull_frame = is_nonnull_frame;
 
+ctx-p_frame = av_frame_alloc();
+if (!ctx-p_frame)
+return AVERROR(ENOMEM);
+
 return 0;
 }
 
diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c
index cf4df18..6eb5b6c 100644
--- a/libavcodec/ivi_common.c
+++ b/libavcodec/ivi_common.c
@@ -968,6 +968,18 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void *data, 
int *got_frame,
 if (ctx-gop_invalid)
 return AVERROR_INVALIDDATA;
 
+if (avctx-codec_id == AV_CODEC_ID_INDEO4 
+ctx-frame_type == IVI4_FRAMETYPE_NULL_LAST) {
+if (ctx-got_p_frame) {
+av_frame_move_ref(data, ctx-p_frame);
+*got_frame = 1;
+ctx-got_p_frame = 0;
+} else {
+*got_frame = 0;
+}
+return buf_size;
+}
+
 if (ctx-gop_flags  IVI5_IS_PROTECTED) {
 avpriv_report_missing_feature(avctx, Password-protected clip!\n);
 return AVERROR_PATCHWELCOME;
@@ -1005,19 +1017,6 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 
 //STOP_TIMER(decode_planes); }
 
-/* If the bidirectional mode is enabled, next I and the following P
- * frame will be sent together. Unfortunately the approach below seems
- * to be the only way to handle the B-frames mode.
- * That's exactly the same Intel decoders do.
- */
-if (avctx-codec_id == AV_CODEC_ID_INDEO4 
-ctx-frame_type == IVI4_FRAMETYPE_INTRA) {
-while (get_bits(ctx-gb, 8)); // skip version string
-skip_bits_long(ctx-gb, 64);  // skip padding, TODO: implement 
correct 8-bytes alignment
-if (get_bits_left(ctx-gb)  18  show_bits(ctx-gb, 18) == 0x3FFF8)
-av_log(avctx, AV_LOG_ERROR, Buffer contains IP frames!\n);
-}
-
 result = ff_set_dimensions(avctx, ctx-planes[0].width, 
ctx-planes[0].height);
 if (result  0)
 return result;
@@ -1041,6 +1040,27 @@ int ff_ivi_decode_frame(AVCodecContext *avctx, void 
*data, int *got_frame,
 
 *got_frame = 1;
 
+/* If the bidirectional mode is enabled, next I and the following P
+ * frame will be sent together. Unfortunately the approach below seems
+ * to be the only way to handle the B-frames mode.
+ * That's exactly the same Intel decoders do.
+ */
+if (avctx-codec_id == AV_CODEC_ID_INDEO4 
+ctx-frame_type == IVI4_FRAMETYPE_INTRA) {
+int left;
+
+while (get_bits(ctx-gb, 8)); // skip version string
+left = get_bits_count(ctx-gb)  0x18;
+skip_bits_long(ctx-gb, 64 - left);
+if (get_bits_left(ctx-gb)  18 
+show_bits_long(ctx-gb, 21) == 0xBFFF8) { // syncheader + inter 
type
+AVPacket pkt;
+pkt.data = avpkt-data + (get_bits_count(ctx-gb)  3);
+pkt.size = get_bits_left(ctx-gb)  3;
+ff_ivi_decode_frame(avctx, ctx-p_frame, ctx-got_p_frame, pkt);
+}
+}
+
 return buf_size;
 }
 
@@ -1073,6 +1093,8 @@ av_cold int ff_ivi_decode_close(AVCodecContext *avctx)
 }
 #endif
 
+av_frame_free(ctx-p_frame);
+
 return 0;
 }
 
diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h
index 584bf07..604b549 100644
--- a/libavcodec/ivi_common.h
+++ b/libavcodec/ivi_common.h
@@ -260,6 +260,9 @@ typedef struct IVI45DecContext {
 int (*is_nonnull_frame)(struct IVI45DecContext *ctx);
 
 int gop_invalid;
+
+AVFrame *p_frame;
+int got_p_frame;
 } IVI45DecContext;
 
 /** compare some properties of two pictures */

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Move Indeo4 frametypes into common header.

2014-06-01 Thread Dirk Ausserhaus
Module: libav
Branch: master
Commit: 3df0d20028cb9d2daca16ac0dc6c3ab77183da37

Author:Dirk Ausserhaus dausserh...@gmail.com
Committer: Kostya Shishkov kostya.shish...@gmail.com
Date:  Thu May 29 13:17:49 2014 +0200

Move Indeo4 frametypes into common header.

Signed-off-by: Kostya Shishkov kostya.shish...@gmail.com

---

 libavcodec/indeo4.c |   49 +--
 libavcodec/ivi_common.c |2 +-
 libavcodec/ivi_common.h |   13 +
 3 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/libavcodec/indeo4.c b/libavcodec/indeo4.c
index 6a19955..ca81d62 100644
--- a/libavcodec/indeo4.c
+++ b/libavcodec/indeo4.c
@@ -34,19 +34,6 @@
 #include ivi_common.h
 #include indeo4data.h
 
-/**
- *  Indeo 4 frame types.
- */
-enum {
-FRAMETYPE_INTRA   = 0,
-FRAMETYPE_INTRA1  = 1,  /// intra frame with slightly different 
bitstream coding
-FRAMETYPE_INTER   = 2,  /// non-droppable P-frame
-FRAMETYPE_BIDIR   = 3,  /// bidirectional frame
-FRAMETYPE_INTER_NOREF = 4,  /// droppable P-frame
-FRAMETYPE_NULL_FIRST  = 5,  /// empty frame with no data
-FRAMETYPE_NULL_LAST   = 6   /// empty frame with no data
-};
-
 #define IVI4_PIC_SIZE_ESC   7
 
 
@@ -132,7 +119,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 }
 
 #if IVI4_STREAM_ANALYSER
-if (ctx-frame_type == FRAMETYPE_BIDIR)
+if (ctx-frame_type == IVI4_FRAMETYPE_BIDIR)
 ctx-has_b_frames = 1;
 #endif
 
@@ -152,7 +139,7 @@ static int decode_pic_hdr(IVI45DecContext *ctx, 
AVCodecContext *avctx)
 ctx-data_size = get_bits1(ctx-gb) ? get_bits(ctx-gb, 24) : 0;
 
 /* null frames don't contain anything else so we just return */
-if (ctx-frame_type = FRAMETYPE_NULL_FIRST) {
+if (ctx-frame_type = IVI4_FRAMETYPE_NULL_FIRST) {
 av_dlog(avctx, Null frame encountered!\n);
 return 0;
 }
@@ -327,7 +314,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, 
IVIBandDesc *band,
 
 band-glob_quant = get_bits(ctx-gb, 5);
 
-if (!get_bits1(ctx-gb) || ctx-frame_type == FRAMETYPE_INTRA) {
+if (!get_bits1(ctx-gb) || ctx-frame_type == IVI4_FRAMETYPE_INTRA) {
 transform_id = get_bits(ctx-gb, 5);
 if (transform_id = FF_ARRAY_ELEMS(transforms) ||
 !transforms[transform_id].inv_trans) {
@@ -462,7 +449,7 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc 
*band,
 offs   = tile-ypos * band-pitch + tile-xpos;
 
 blks_per_mb  = band-mb_size   != band-blk_size  ? 4 : 1;
-mb_type_bits = ctx-frame_type == FRAMETYPE_BIDIR ? 2 : 1;
+mb_type_bits = ctx-frame_type == IVI4_FRAMETYPE_BIDIR ? 2 : 1;
 
 /* scale factor for motion vectors */
 mv_scale = (ctx-planes[0].bands[0].mb_size  3) - (band-mb_size  3);
@@ -477,7 +464,7 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc 
*band,
 mb-buf_offs = mb_offset;
 
 if (get_bits1(ctx-gb)) {
-if (ctx-frame_type == FRAMETYPE_INTRA) {
+if (ctx-frame_type == IVI4_FRAMETYPE_INTRA) {
 av_log(avctx, AV_LOG_ERROR, Empty macroblock in an INTRA 
picture!\n);
 return AVERROR_INVALIDDATA;
 }
@@ -508,8 +495,8 @@ static int decode_mb_info(IVI45DecContext *ctx, IVIBandDesc 
*band,
 if (!ref_mb)
 return AVERROR_INVALIDDATA;
 mb-type = ref_mb-type;
-} else if (ctx-frame_type == FRAMETYPE_INTRA ||
-   ctx-frame_type == FRAMETYPE_INTRA1) {
+} else if (ctx-frame_type == IVI4_FRAMETYPE_INTRA ||
+   ctx-frame_type == IVI4_FRAMETYPE_INTRA1) {
 mb-type = 0; /* mb_type is always INTRA for intra-frames 
*/
 } else {
 mb-type = get_bits(ctx-gb, mb_type_bits);
@@ -577,29 +564,29 @@ static int decode_mb_info(IVI45DecContext *ctx, 
IVIBandDesc *band,
 static void switch_buffers(IVI45DecContext *ctx)
 {
 switch (ctx-prev_frame_type) {
-case FRAMETYPE_INTRA:
-case FRAMETYPE_INTRA1:
-case FRAMETYPE_INTER:
+case IVI4_FRAMETYPE_INTRA:
+case IVI4_FRAMETYPE_INTRA1:
+case IVI4_FRAMETYPE_INTER:
 ctx-buf_switch ^= 1;
 ctx-dst_buf = ctx-buf_switch;
 ctx-ref_buf = ctx-buf_switch ^ 1;
 break;
-case FRAMETYPE_INTER_NOREF:
+case IVI4_FRAMETYPE_INTER_NOREF:
 break;
 }
 
 switch (ctx-frame_type) {
-case FRAMETYPE_INTRA:
-case FRAMETYPE_INTRA1:
+case IVI4_FRAMETYPE_INTRA:
+case IVI4_FRAMETYPE_INTRA1:
 ctx-buf_switch = 0;
 /* FALLTHROUGH */
-case FRAMETYPE_INTER:
+case IVI4_FRAMETYPE_INTER:
 ctx-dst_buf = ctx-buf_switch;
 ctx-ref_buf = ctx-buf_switch ^ 1;
 break;
-case FRAMETYPE_INTER_NOREF:
-case FRAMETYPE_NULL_FIRST:
-case FRAMETYPE_NULL_LAST:
+

[libav-commits] Update Changelog for 0.8.12

2014-06-01 Thread Sean McGovern
Module: libav
Branch: release/0.8
Commit: d75b149757fce813cd73ba12463f324cc2bba4ed

Author:Sean McGovern gsean...@gmail.com
Committer: Sean McGovern gsean...@gmail.com
Date:  Sun Jun  1 14:20:46 2014 -0400

Update Changelog for 0.8.12

---

 Changelog |   35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/Changelog b/Changelog
index 6323e02..64a3422 100644
--- a/Changelog
+++ b/Changelog
@@ -1,6 +1,40 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version 0.8.12:
+
+- h264: set parameters from SPS whenever it changes
+- alac: Limit max_samples_per_frame
+- swscale: Fix an undefined behaviour
+- apedec: do not buffer decoded samples over AVPackets
+- isom: lpcm in mov default to big endian
+- movdec: handle 0x7fff langcode as macintosh per the specs
+- avi: Improve non-interleaved detection
+- h264: reset next_output_pic earlier in start_frame()
+- tiffdec: use bytestream2 to simplify overread/overwrite protection
+- bytestream: add bytestream2_copy_buffer() functions
+- bytestream: add functions for accessing size of buffer
+- movenc: allow override of writing application tag
+- matroskaenc: allow override of writing application tag
+- avfilter: Add missing emms_c when needed
+- mpeg12: check scantable indices in all decode_block functions
+- sgidec: fix buffer size check in expand_rle_row()
+- adx: check that the offset is not negative
+- mpegvideo: set reference/pict_type on generated reference frames
+- h264: reset data partitioning at the beginning of each decode call
+- h264: reset ref count if decoding the slice header fails
+- h264: reset first_field if frame_start() fails for missing refs
+- h264: limit allowed pred modes in ff_h264_check_intra_pred_mode() to 3
+- h264: reject mismatching luma/chroma bit depths during sps parsing
+- h264: check that execute_decode_slices() is not called too many times
+- h264: do not use 422 functions for monochrome
+- h264: reset data_partitioning if decoding the slice header for NAL_DPA fails
+- h264_refs: make sure not to write over the bounds of the default ref list
+- h264: check buffer size before accessing it
+- configure: use utilities from /usr/xpg4/bin if it exists
+- cmdutils: update copyright year to 2014.
+- ituh263: reject b-frame with pp_time = 0
+
 version 0.8.11:
 
 - configure: Update freetype check to follow upstream
@@ -20,7 +54,6 @@ version 0.8.11:
 - Prepare for 0.8.11 Release
 - lavf: make av_probe_input_buffer more robust
 
-
 version 0.8.10:
 
 - oggparseogm: check timing variables

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] Add some bug references

2014-06-01 Thread Reinhard Tartler
Module: libav
Branch: release/0.8
Commit: 9552b37e2604552d5ff210175d6baf28ccc2bb80

Author:Reinhard Tartler siret...@tauware.de
Committer: Reinhard Tartler siret...@tauware.de
Date:  Sun Jun  1 16:12:58 2014 -0400

Add some bug references

---

 Changelog |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Changelog b/Changelog
index 64a3422..d325786 100644
--- a/Changelog
+++ b/Changelog
@@ -6,11 +6,11 @@ version 0.8.12:
 - h264: set parameters from SPS whenever it changes
 - alac: Limit max_samples_per_frame
 - swscale: Fix an undefined behaviour
-- apedec: do not buffer decoded samples over AVPackets
+- apedec: do not buffer decoded samples over AVPackets (debian/744901)
 - isom: lpcm in mov default to big endian
 - movdec: handle 0x7fff langcode as macintosh per the specs
-- avi: Improve non-interleaved detection
-- h264: reset next_output_pic earlier in start_frame()
+- avi: Improve non-interleaved detection (libav/666)
+- h264: reset next_output_pic earlier in start_frame() (libav/672, 
debian/741240, ubuntu/1288206)
 - tiffdec: use bytestream2 to simplify overread/overwrite protection
 - bytestream: add bytestream2_copy_buffer() functions
 - bytestream: add functions for accessing size of buffer

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits


[libav-commits] rtmppkt: Add method to read an AMF string that is not prefixed by its type

2014-06-01 Thread Uwe L. Korn
Module: libav
Branch: master
Commit: 3b18857ab301d2a0b3e86e9d85eed76f0798a29c

Author:Uwe L. Korn uw...@xhochy.com
Committer: Martin Storsjö mar...@martin.st
Date:  Sat May 31 20:37:25 2014 +0100

rtmppkt: Add method to read an AMF string that is not prefixed by its type

Signed-off-by: Martin Storsjö mar...@martin.st

---

 libavformat/rtmppkt.c |   14 ++
 libavformat/rtmppkt.h |   17 +
 2 files changed, 27 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtmppkt.c b/libavformat/rtmppkt.c
index 306a243..37fbb5f 100644
--- a/libavformat/rtmppkt.c
+++ b/libavformat/rtmppkt.c
@@ -102,13 +102,11 @@ int ff_amf_read_number(GetByteContext *bc, double *val)
 return 0;
 }
 
-int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
-   int strsize, int *length)
+int ff_amf_get_string(GetByteContext *bc, uint8_t *str,
+  int strsize, int *length)
 {
 int stringlen = 0;
 int readsize;
-if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_STRING)
-return AVERROR_INVALIDDATA;
 stringlen = bytestream2_get_be16(bc);
 if (stringlen + 1  strsize)
 return AVERROR(EINVAL);
@@ -122,6 +120,14 @@ int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
 return 0;
 }
 
+int ff_amf_read_string(GetByteContext *bc, uint8_t *str,
+   int strsize, int *length)
+{
+if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_STRING)
+return AVERROR_INVALIDDATA;
+return ff_amf_get_string(bc, str, strsize, length);
+}
+
 int ff_amf_read_null(GetByteContext *bc)
 {
 if (bytestream2_get_byte(bc) != AMF_DATA_TYPE_NULL)
diff --git a/libavformat/rtmppkt.h b/libavformat/rtmppkt.h
index e973684..149c153 100644
--- a/libavformat/rtmppkt.h
+++ b/libavformat/rtmppkt.h
@@ -278,6 +278,23 @@ int ff_amf_read_bool(GetByteContext *gbc, int *val);
 int ff_amf_read_number(GetByteContext *gbc, double *val);
 
 /**
+ * Get AMF string value.
+ *
+ * This function behaves the same as ff_amf_read_string except that
+ * it does not expect the AMF type prepended to the actual data.
+ * Appends a trailing null byte to output string in order to
+ * ease later parsing.
+ *
+ *@param[in,out] gbc GetByteContext initialized with AMF-formatted data
+ *@param[out]str read string
+ *@param[in] strsize buffer size available to store the read string
+ *@param[out]length  read string length
+ *@return 0 on success or an AVERROR code on failure
+*/
+int ff_amf_get_string(GetByteContext *bc, uint8_t *str,
+  int strsize, int *length);
+
+/**
  * Read AMF string value.
  *
  * Appends a trailing null byte to output string in order to

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] rtmpproto: read metadata to set correct FLV header

2014-06-01 Thread Uwe L. Korn
Module: libav
Branch: master
Commit: 59cb5747ec3c5cd842b94e574c37889521c97cc4

Author:Uwe L. Korn uw...@xhochy.com
Committer: Martin Storsjö mar...@martin.st
Date:  Sat May 31 20:37:26 2014 +0100

rtmpproto: read metadata to set correct FLV header

In the presence of no metadata, do not set any stream flag in the FLV
header but let the demuxer handle the detection and creation of streams
as data arrives.

Signed-off-by: Martin Storsjö mar...@martin.st

---

 libavformat/rtmpproto.c |   66 ++-
 1 file changed, 65 insertions(+), 1 deletion(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 0cc702a..de09486 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -97,6 +97,9 @@ typedef struct RTMPContext {
 uint32_t  bytes_read; /// number of bytes read from 
server
 uint32_t  last_bytes_read;/// number of bytes read last 
reported to server
 int   skip_bytes; /// number of bytes to skip 
from the input FLV stream in the next write call
+int   has_audio;  /// presence of audio data
+int   has_video;  /// presence of video data
+int   received_metadata;  /// Indicates if we have 
received metadata about the streams
 uint8_t   flv_header[RTMP_HEADER];/// partial incoming flv packet 
header
 int   flv_header_bytes;   /// number of initialized bytes 
in flv_header
 int   nb_invokes; /// keeps track of invoke 
messages
@@ -2109,6 +2112,12 @@ static int append_flv_data(RTMPContext *rt, RTMPPacket 
*pkt, int skip)
 const int size  = pkt-size - skip;
 uint32_t ts = pkt-timestamp;
 
+if (pkt-type == RTMP_PT_AUDIO) {
+rt-has_audio = 1;
+} else if (pkt-type == RTMP_PT_VIDEO) {
+rt-has_video = 1;
+}
+
 old_flv_size = update_offset(rt, size + 15);
 
 if ((ret = av_reallocp(rt-flv_data, rt-flv_size))  0) {
@@ -2141,6 +2150,38 @@ static int handle_notify(URLContext *s, RTMPPacket *pkt)
stringlen))
 return AVERROR_INVALIDDATA;
 
+if (!strcmp(commandbuffer, onMetaData)) {
+// metadata properties should be stored in a mixed array
+if (bytestream2_get_byte(gbc) == AMF_DATA_TYPE_MIXEDARRAY) {
+// We have found a metaData Array so flv can determine the streams
+// from this.
+rt-received_metadata = 1;
+// skip 32-bit max array index
+bytestream2_skip(gbc, 4);
+while (bytestream2_get_bytes_left(gbc)  3) {
+if (ff_amf_get_string(gbc, statusmsg, sizeof(statusmsg),
+  stringlen))
+return AVERROR_INVALIDDATA;
+// We do not care about the content of the property (yet).
+stringlen = ff_amf_tag_size(gbc.buffer, gbc.buffer_end);
+if (stringlen  0)
+return AVERROR_INVALIDDATA;
+bytestream2_skip(gbc, stringlen);
+
+// The presence of the following properties indicates that the
+// respective streams are present.
+if (!strcmp(statusmsg, videocodecid)) {
+rt-has_video = 1;
+}
+if (!strcmp(statusmsg, audiocodecid)) {
+rt-has_audio = 1;
+}
+}
+if (bytestream2_get_be24(gbc) != AMF_END_OF_OBJECT)
+return AVERROR_INVALIDDATA;
+}
+}
+
 // Skip the @setDataFrame string and validate it is a notification
 if (!strcmp(commandbuffer, @setDataFrame)) {
 skip = gbc.buffer - pkt-data;
@@ -2571,6 +2612,9 @@ reconnect:
 
 rt-client_report_size = 1048576;
 rt-bytes_read = 0;
+rt-has_audio = 0;
+rt-has_video = 0;
+rt-received_metadata = 0;
 rt-last_bytes_read = 0;
 rt-server_bw = 250;
 
@@ -2610,7 +2654,27 @@ reconnect:
 if ((err = av_reallocp(rt-flv_data, rt-flv_size))  0)
 return err;
 rt-flv_off  = 0;
-memcpy(rt-flv_data, FLV\1\5\0\0\0\011\0\0\0\0, rt-flv_size);
+memcpy(rt-flv_data, FLV\1\0\0\0\0\011\0\0\0\0, rt-flv_size);
+
+// Read packets until we reach the first A/V packet or read metadata.
+// If there was a metadata package in front of the A/V packets, we can
+// build the FLV header from this. If we do not receive any metadata,
+// the FLV decoder will allocate the needed streams when their first
+// audio or video packet arrives.
+while (!rt-has_audio  !rt-has_video  !rt-received_metadata) {
+if ((ret = get_packet(s, 0))  0)
+   return ret;
+}
+
+// Either after we have read the metadata or (if there is none) the
+// first packet of an A/V stream, we have a 

[libav-commits] flvdec: Do not default to a video and audio stream

2014-06-01 Thread Uwe L. Korn
Module: libav
Branch: master
Commit: a1859032e39d96352687186fd179e1559dea2aca

Author:Uwe L. Korn uw...@xhochy.com
Committer: Martin Storsjö mar...@martin.st
Date:  Sat May 31 17:53:01 2014 +0100

flvdec: Do not default to a video and audio stream

If no streams were indicated in the FLV header, do not automatically
allocate by default a video and an audio stream. Instead, in the case
that the header did not indicate the presence of any data, allocate no
stream until data actually arrives for one type.

Signed-off-by: Martin Storsjö mar...@martin.st

---

 libavformat/flvdec.c |8 
 1 file changed, 8 deletions(-)

diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 3772cd9..8e4cc5e 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -559,14 +559,6 @@ static int flv_read_header(AVFormatContext *s)
 
 avio_skip(s-pb, 4);
 flags = avio_r8(s-pb);
-/* old flvtool cleared this field */
-/* FIXME: better fix needed */
-if (!flags) {
-flags = FLV_HEADER_FLAG_HASVIDEO | FLV_HEADER_FLAG_HASAUDIO;
-av_log(s, AV_LOG_WARNING,
-   Broken FLV file, which says no streams present, 
-   this might fail.\n);
-}
 
 s-ctx_flags |= AVFMTCTX_NOHEADER;
 

___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits

[libav-commits] Tag v0.8.12 : 0.8.12 Release

2014-06-01 Thread Reinhard Tartler
Module: libav
Branch: refs/tags/v0.8.12
Tag:c2d403f08f960f733ce6b3723df50c96466213a1

Tagger: Reinhard Tartler siret...@tauware.de
Date:   Sun Jun  1 16:39:43 2014 -0400

0.8.12 Release
___
libav-commits mailing list
libav-commits@libav.org
https://lists.libav.org/mailman/listinfo/libav-commits