[FFmpeg-devel] [PATCH 1/5] Metadata attribute passing in ASF
Michael Niedermayer
michaelni at gmx.at
Wed Jul 1 14:55:14 CEST 2015
On Wed, Jul 01, 2015 at 02:27:30PM +0300, Vadim Belov wrote:
> ---
> ffmpeg.c | 7 ++-
> libavformat/asf.h | 9 ++-
> libavformat/asfdec.c | 32 +++++++++-
> libavformat/asfenc.c | 60 ++++++++++++++++---
> libavformat/cache.c | 6 +-
> libavformat/dashenc.c | 6 +-
> libavformat/file.c | 6 +-
> libavformat/hdsenc.c | 6 +-
> libavformat/hlsenc.c | 6 +-
> libavformat/smoothstreamingenc.c | 6 +-
> libavutil/file.c | 6 +-
> libavutil/file_open.c | 6 +-
> libavutil/log.c | 6 +-
> libavutil/random_seed.c | 6 +-
> libavutil/time.c | 6 +-
> tests/ref/fate/sub-aqtitle | 90 ++++++++++++++--------------
> tests/ref/fate/sub-charenc | 124 +++++++++++++++++++--------------------
> tests/ref/fate/sub-jacosub | 46 +++++++--------
> tests/ref/fate/sub-microdvd | 44 +++++++-------
> tests/ref/fate/sub-movtext | 30 +++++-----
> tests/ref/fate/sub-mpl2 | 32 +++++-----
> tests/ref/fate/sub-mpsub | 66 ++++++++++-----------
> tests/ref/fate/sub-mpsub-frames | 28 ++++-----
> tests/ref/fate/sub-pjs | 30 +++++-----
> tests/ref/fate/sub-realtext | 34 +++++------
> tests/ref/fate/sub-sami | 42 ++++++-------
> tests/ref/fate/sub-srt | 98 +++++++++++++++----------------
> tests/ref/fate/sub-stl | 58 +++++++++---------
> tests/ref/fate/sub-subripenc | 4 +-
> tests/ref/fate/sub-subviewer | 30 +++++-----
> tests/ref/fate/sub-subviewer1 | 44 +++++++-------
> tests/ref/fate/sub-vplayer | 30 +++++-----
> tests/ref/fate/sub-webvtt | 54 ++++++++---------
> 33 files changed, 569 insertions(+), 489 deletions(-)
>
> diff --git a/ffmpeg.c b/ffmpeg.c
> index a89ae39..a3cca09 100644
> --- a/ffmpeg.c
> +++ b/ffmpeg.c
> @@ -36,9 +36,6 @@
> #if HAVE_IO_H
> #include <io.h>
> #endif
> -#if HAVE_UNISTD_H
> -#include <unistd.h>
> -#endif
> #endif
>
> #include "libavformat/avformat.h"
> @@ -75,6 +72,10 @@
> #elif HAVE_GETPROCESSTIMES
> #include <windows.h>
> #endif
> +#if HAVE_UNISTD_H
> +#include <unistd.h>
> +#endif
unrelated
> +
> #if HAVE_GETPROCESSMEMORYINFO
> #include <windows.h>
> #include <psapi.h>
> diff --git a/libavformat/asf.h b/libavformat/asf.h
> index 0c9598a..6dce410 100644
> --- a/libavformat/asf.h
> +++ b/libavformat/asf.h
> @@ -26,7 +26,11 @@
> #include "metadata.h"
> #include "riff.h"
>
> -#define PACKET_SIZE 3200
> +// Packet size according to the size that ACX File Creator writes to its output packets:
> +// ASF_PACKET_SIZE is 8192, but in CASFFile::InitAsfPckt it is decremented! Most possibly by 100
> +// Bottom line: in the ASF core file the value is 8032
> +#define PACKET_SIZE 8032
> +//#define PACKET_SIZE 3200
this probably should be in a seperate patch
the text from the comment can possibly be duplciated in the commit
message or moved into it
>
> typedef struct ASFPayload {
> uint8_t type;
> @@ -189,4 +193,7 @@ extern const AVMetadataConv ff_asf_metadata_conv[];
>
> extern AVInputFormat ff_asf_demuxer;
>
> +// TODO: move to .c ?
> +#define DIRECTION_DICT_KEY "direction"
> +
> #endif /* AVFORMAT_ASF_H */
> diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
> index 359ee8b..bf4ef75 100644
> --- a/libavformat/asfdec.c
> +++ b/libavformat/asfdec.c
> @@ -39,6 +39,8 @@
> #include "asf.h"
> #include "asfcrypt.h"
>
> +#define NO_STREAM_DIRECTION -1
> +
> typedef struct ASFContext {
> const AVClass *class;
> int asfid2avid[128]; ///< conversion table from asf ID 2 AVStream ID
> @@ -81,6 +83,10 @@ typedef struct ASFContext {
>
> int no_resync_search;
> int export_xmp;
> + int direction[128];
> + //AVRational direction[128]; ///< pair: num={ 0 = doesn't have direction, 1 = has direction }
> + // ///< den={ direction value }
iam not sure the outcomented stuff should be in git
> +
> } ASFContext;
>
> static const AVOption options[] = {
> @@ -671,7 +677,9 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
> avio_skip(pb, name_len - ret);
> av_log(s, AV_LOG_TRACE, "%d stream %d name_len %2d type %d len %4d <%s>\n",
> i, stream_num, name_len, value_type, value_len, name);
> -
> +
> + asf->direction[stream_num] = NO_STREAM_DIRECTION;
> +
> if (!strcmp(name, "AspectRatioX")){
> int aspect_x = get_value(s->pb, value_type, 16);
> if(stream_num < 128)
> @@ -680,7 +688,16 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
> int aspect_y = get_value(s->pb, value_type, 16);
> if(stream_num < 128)
> asf->dar[stream_num].den = aspect_y;
> - } else {
> + } else if(!strcmp(name, "streamDirection") && // V
> + 0 < stream_num){ // V
git keeps track of authorship (see git blame) theres no need to
add comments saying fro whom a line is
> + int direction = get_value(s->pb, value_type, value_len);
> +
> + av_log(s, AV_LOG_INFO, "+++++++++++++++ stream %d Direction is %d\n", // V
> + stream_num, direction);
debuging leftover ?
if so it doesnt belong in a submitted patch
> +
> + asf->direction[stream_num] = direction;
> +
> + } else {
> get_tag(s, name, value_type, value_len, 16);
> }
> }
> @@ -855,6 +872,17 @@ static int asf_read_header(AVFormatContext *s)
> &st->sample_aspect_ratio.den,
> asf->dar[0].num, asf->dar[0].den, INT_MAX);
>
> +
> + if(asf->direction[i] != NO_STREAM_DIRECTION) {
> + char buffer[32];
> + sprintf(buffer, "%d %d", i, asf->direction[i]);
never use sprintf() always snprintf(), its more secure as it checks
the length
> +
> + av_log(s, AV_LOG_INFO, "++++++++++++ setting str direction %s in stream (%d,%d)\n",
> + buffer, i, stream_num);
> + //av_dict_set(&s->streams[i]->metadata, DIRECTION_DICT_KEY, buffer, 0);
doesnt look like it belongs in a submited patch
> + av_dict_set(&st->metadata, DIRECTION_DICT_KEY, buffer, 0);
> + }
> +
> av_log(s, AV_LOG_TRACE, "i=%d, st->codec->codec_type:%d, asf->dar %d:%d sar=%d:%d\n",
> i, st->codec->codec_type, asf->dar[i].num, asf->dar[i].den,
> st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
> diff --git a/libavformat/asfenc.c b/libavformat/asfenc.c
> index 015c731..59673d2 100644
> --- a/libavformat/asfenc.c
> +++ b/libavformat/asfenc.c
> @@ -218,7 +218,9 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
> { AV_CODEC_ID_NONE, 0 },
> };
>
> -#define PREROLL_TIME 3100
> +// V: in order to keep preroll time 0 redefine:
> +#define PREROLL_TIME 0
> +//#define PREROLL_TIME 3100
why should the preroll be kept 0 ?
also it could be made user configureable
see preload in libavformat/mpegenc.c for a similar example
>
> static void put_str16(AVIOContext *s, const char *tag)
> {
> @@ -350,27 +352,33 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
> AVDictionaryEntry *tags[5];
> int header_size, n, extra_size, extra_size2, wav_extra_size, file_time;
> int has_title, has_aspect_ratio = 0;
> - int metadata_count;
> + int has_direction = 0; // V
> + int metadata_count;
> AVCodecContext *enc;
> int64_t header_offset, cur_pos, hpos;
> int bit_rate;
> int64_t duration;
>
> ff_metadata_conv(&s->metadata, ff_asf_metadata_conv, NULL);
> -
> +
> + av_log(s, AV_LOG_ERROR, "============ ASF Streams num is %d\n", s->nb_streams); // V
more debug cruft that shouldnt be in the patch
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Frequently ignored answer#1 FFmpeg bugs should be sent to our bugtracker. User
questions about the command line tools should be sent to the ffmpeg-user ML.
And questions about how to use libav* should be sent to the libav-user ML.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20150701/dfcebc8f/attachment.asc>
More information about the ffmpeg-devel
mailing list