[FFmpeg-devel] [PATCH 5/5] tabs to spaces and comments
Vadim Belov
vadim.belov at gmail.com
Wed Jul 1 12:12:33 CEST 2015
From: Vadim Belov <vadimb at VADIMB-T440.nice.com>
---
libavformat/asf.h | 8 +-
libavformat/asf_ex.h | 29 ++--
libavformat/asf_trim.c | 366 ++++++++++++++++++++++++------------------------
libavformat/asf_trim.h | 42 +++---
libavformat/asfdec.c | 24 ++--
libavformat/asfenc.c | 105 +++++++-------
libavformat/concatdec.c | 2 +-
7 files changed, 298 insertions(+), 278 deletions(-)
diff --git a/libavformat/asf.h b/libavformat/asf.h
index 7e8d8d3..0ef4ea6 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -29,7 +29,9 @@
#define PACKET_SIZE 3200
-// "asf_ex.h" is IMPORTANT to be placed After PACKET_SIZE definition
+/**
+ * "asf_ex.h" is IMPORTANT to be placed After PACKET_SIZE definition
+ */
#include "asf_ex.h"
typedef struct ASFPayload {
@@ -61,9 +63,9 @@ typedef struct ASFStream {
uint32_t palette[256];
int payload_ext_ct;
- ASFPayload payload[8];
+ ASFPayload payload[8];
- ASFIndexData idx_data;
+ ASFIndexData idx_data;
} ASFStream;
typedef struct ASFMainHeader {
diff --git a/libavformat/asf_ex.h b/libavformat/asf_ex.h
index 6655424..480105a 100644
--- a/libavformat/asf_ex.h
+++ b/libavformat/asf_ex.h
@@ -1,4 +1,8 @@
-/*
+/**
+ * @file asf_ex.h
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
* Copyright (c) 2015 Vadim Belov
*
* This file is part of FFmpeg.
@@ -23,9 +27,12 @@
#include <stdint.h>
-// 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.
-// Bottom line: in the ASF core file the value is 8032
+/**
+ * Packet size according to the size that Custom ASF File Creator writes
+ * to its output packets:
+ * ASF_PACKET_SIZE is 8192, but is decremented later.
+ * Final result: in the ASF core file the value is 8032
+ */
#ifdef PACKET_SIZE
#undef PACKET_SIZE
#endif
@@ -36,16 +43,16 @@
#define NO_STREAM_DIRECTION -1
#define ASF_MAX_STREAMS_NUM 128
-typedef struct ASFStreamIndex { // Index Entry value
- uint64_t offset;
+typedef struct ASFStreamIndex { // Index Entry value
+ uint64_t offset;
} ASFStreamIndex;
typedef struct ASFIndexData {
- ASFStreamIndex* indices; // array of ASFStreamIndex
- uint32_t indices_max_count; // allocated size
- uint32_t next_duration_mark; // for next index
- uint32_t indices_count; // current index
- int64_t duration_overall;
+ ASFStreamIndex* indices; // array of ASFStreamIndex
+ uint32_t indices_max_count; // allocated size
+ uint32_t next_duration_mark; // for next index
+ uint32_t indices_count; // current index
+ int64_t duration_overall;
} ASFIndexData;
#endif /* AVFORMAT_ASF_EX_H */
diff --git a/libavformat/asf_trim.c b/libavformat/asf_trim.c
index 60017e4..ce75170 100644
--- a/libavformat/asf_trim.c
+++ b/libavformat/asf_trim.c
@@ -1,21 +1,25 @@
/*
-* Copyright (c) 2015 Vadim Belov
-*
-* This file is part of FFmpeg.
-*
-* FFmpeg is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* FFmpeg is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with FFmpeg; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * @file asf_trim.c
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
+ * Copyright (c) 2015 Vadim Belov
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "asf_trim.h"
@@ -23,202 +27,202 @@
#define ASF_INDEX_ENTRY_TIME_INTERVAL 10000
#define SPECIFIER_INDEX_TYPE 3
-#define BLOCK_PART 0xFFFFFFFF00000000
-#define OFFSET_PART 0x00000000FFFFFFFF
-#define INVALID_OFFSET 0xFFFFFFFF
+#define BLOCK_PART 0xFFFFFFFF00000000
+#define OFFSET_PART 0x00000000FFFFFFFF
+#define INVALID_OFFSET 0xFFFFFFFF
int asf_get_streams_direction(AVFormatContext *s)
{
- int ret = 0;
- int n;
- for (n = 0; n < s->nb_streams; n++) {
- AVDictionaryEntry *t = av_dict_get(
- s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
-
- av_log(s, AV_LOG_DEBUG, "direction metadata ptr is %p\n", t);
-
- if (t) ret++;
- }
- return ret;
+ int ret = 0;
+ int n;
+ for (n = 0; n < s->nb_streams; n++) {
+ AVDictionaryEntry *t = av_dict_get(
+ s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
+
+ av_log(s, AV_LOG_DEBUG, "direction metadata ptr is %p\n", t);
+
+ if (t) ret++;
+ }
+ return ret;
}
void set_stream_direction(
- AVFormatContext *s,
- int direction[ASF_MAX_STREAMS_NUM],
- AVStream *st,
- int i)
+ AVFormatContext *s,
+ int direction[ASF_MAX_STREAMS_NUM],
+ AVStream *st,
+ int i)
{
- if(direction[i] != NO_STREAM_DIRECTION) {
- char buffer[32];
- sprintf(buffer, "%d %d", i, direction[i]);
- av_dict_set(&st->metadata, DIRECTION_DICT_KEY, buffer, 0);
- }
+ if(direction[i] != NO_STREAM_DIRECTION) {
+ char buffer[32];
+ sprintf(buffer, "%d %d", i, direction[i]);
+ av_dict_set(&st->metadata, DIRECTION_DICT_KEY, buffer, 0);
+ }
}
int asf_alloc_streams_index(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams,
- int block_size)
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams,
+ int block_size)
{
- int i;
- for (i = 0; i < num_streams; ++i){
- ASFIndexData *idx = &streams[i].idx_data;
+ int i;
+ for (i = 0; i < num_streams; ++i){
+ ASFIndexData *idx = &streams[i].idx_data;
- idx->indices = av_malloc(sizeof(ASFStreamIndex)* block_size);
- if (!idx->indices) return AVERROR(ENOMEM);
+ idx->indices = av_malloc(sizeof(ASFStreamIndex)* block_size);
+ if (!idx->indices) return AVERROR(ENOMEM);
- idx->indices_max_count = block_size;
- idx->duration_overall = 0;
- idx->next_duration_mark = 0;
- idx->indices_count = 0;
- }
+ idx->indices_max_count = block_size;
+ idx->duration_overall = 0;
+ idx->next_duration_mark = 0;
+ idx->indices_count = 0;
+ }
- return 0;
+ return 0;
}
void asf_free_streams_index(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams)
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams)
{
- int i;
- for (i = 0; i < num_streams; ++i) {
- av_freep(&streams[i].idx_data.indices);
- }
+ int i;
+ for (i = 0; i < num_streams; ++i) {
+ av_freep(&streams[i].idx_data.indices);
+ }
}
int upadte_indices(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- uint64_t pkt_time,
- uint64_t packet_offset,
- int stream_index,
- int64_t pkt_duration,
- uint32_t asf_index_block,
- uint64_t asf_data_start)
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ uint64_t pkt_time,
+ uint64_t packet_offset,
+ int stream_index,
+ int64_t pkt_duration,
+ uint32_t asf_index_block,
+ uint64_t asf_data_start)
{
- ASFIndexData *idx = &streams[stream_index].idx_data;
-
- // reallocate if size too small
- if (idx->indices_count > idx->indices_max_count) {
- int err;
- idx->indices_max_count = (pkt_time + asf_index_block) & ~(asf_index_block - 1);
- if ((err = av_reallocp_array(&idx,
- idx->indices_max_count,
- sizeof(*idx->indices))) < 0) {
- idx->indices_max_count = 0;
- return err;
- }
- }
-
- // update offset if reached the duration mark
- idx->duration_overall += pkt_duration;
- if (idx->duration_overall > idx->next_duration_mark) {
- idx->indices[idx->indices_count].offset = packet_offset - asf_data_start;
- idx->indices_count++;
- idx->next_duration_mark += ASF_INDEX_ENTRY_TIME_INTERVAL;
- }
-
- return 0;
+ ASFIndexData *idx = &streams[stream_index].idx_data;
+
+ // reallocate if size too small
+ if (idx->indices_count > idx->indices_max_count) {
+ int err;
+ idx->indices_max_count = (pkt_time + asf_index_block) & ~(asf_index_block - 1);
+ if ((err = av_reallocp_array(&idx,
+ idx->indices_max_count,
+ sizeof(*idx->indices))) < 0) {
+ idx->indices_max_count = 0;
+ return err;
+ }
+ }
+
+ // update offset if reached the duration mark
+ idx->duration_overall += pkt_duration;
+ if (idx->duration_overall > idx->next_duration_mark) {
+ idx->indices[idx->indices_count].offset = packet_offset - asf_data_start;
+ idx->indices_count++;
+ idx->next_duration_mark += ASF_INDEX_ENTRY_TIME_INTERVAL;
+ }
+
+ return 0;
}
static int get_num_entries(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams)
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams)
{
- int i;
- int ret = 0;
- for (i = 0; i < num_streams; ++i){
- ASFIndexData *idx = &(streams[i].idx_data);
- ret = FFMAX(ret, idx->indices_count);
- }
- return ret;
+ int i;
+ int ret = 0;
+ for (i = 0; i < num_streams; ++i){
+ ASFIndexData *idx = &(streams[i].idx_data);
+ ret = FFMAX(ret, idx->indices_count);
+ }
+ return ret;
}
static int should_iterate_block(int i, ASFIndexData *idx, uint64_t curr_offset)
{
- if (i + 1 < idx->indices_count) {
- uint64_t next_offset = idx->indices[i + 1].offset;
- uint64_t curr_block = curr_offset & BLOCK_PART;
- uint64_t next_block = next_offset & BLOCK_PART;
- return curr_block != next_block;
- }
-
- return 0;
+ if (i + 1 < idx->indices_count) {
+ uint64_t next_offset = idx->indices[i + 1].offset;
+ uint64_t curr_block = curr_offset & BLOCK_PART;
+ uint64_t next_block = next_offset & BLOCK_PART;
+ return curr_block != next_block;
+ }
+
+ return 0;
}
int asf_write_indices(
- AVFormatContext *s,
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams)
+ AVFormatContext *s,
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams)
{
- AVIOContext *pb = s->pb;
-
- int i, j;
- int num_blocks = 0;
- int num_entries = get_num_entries(streams, num_streams);
-
- int64_t blocks_pos, end_of_indices;
-
- char write_index = 1;
- char iterate_block = 1;
-
- av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries.\n",
- num_streams, num_entries);
-
- ff_put_guid(pb, &ff_asf_index_header);
- avio_wl64(pb, 34 + 4 * num_streams + 4 + 8 * num_streams + 4 * num_entries*num_streams);
- avio_wl32(pb, ASF_INDEX_ENTRY_TIME_INTERVAL); // interval
- avio_wl16(pb, num_streams); // specifiers count
-
- blocks_pos = avio_tell(pb);
- avio_wl32(pb, 0); // rewrite later
-
- // write specifiers
- for (i = 0; i < num_streams; i++) {
- avio_wl16(pb, i + 1);
- avio_wl16(pb, SPECIFIER_INDEX_TYPE);
- }
-
- avio_wl32(pb, num_entries); // Index Entry Count
-
- for (i = 0; write_index && i < num_entries; ++i) {
-
- // block header
- if (iterate_block) {
- ++num_blocks;
-
- for (j = 0; j < num_streams; ++j) {
- avio_wl64(pb, 0);
- }
- iterate_block = 0;
- }
-
- // block content
- for (j = 0; j < num_streams; ++j) {
- ASFIndexData *idx = &(streams[j].idx_data);
- uint32_t offset = INVALID_OFFSET;
- if (i < idx->indices_count) {
- uint64_t full_offset = idx->indices[i].offset;
- offset = (uint32_t)full_offset & OFFSET_PART;
- iterate_block = should_iterate_block(i, idx, full_offset);
- }
- else {
- write_index = 0;
- offset = INVALID_OFFSET;
- av_log(s, AV_LOG_WARNING, "Index: invalid offset (%d,%d)\n", i, j);
- }
- avio_wl32(pb, offset);
- }
- }
-
- end_of_indices = avio_tell(pb);
-
- // rewrite blocks count and return file descriptor to end
- avio_seek(pb, blocks_pos, SEEK_SET);
- avio_wl32(pb, num_blocks);
- avio_seek(pb, end_of_indices, SEEK_SET);
-
- av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries done.\n",
- num_streams, num_entries);
-
- return 0;
+ AVIOContext *pb = s->pb;
+
+ int i, j;
+ int num_blocks = 0;
+ int num_entries = get_num_entries(streams, num_streams);
+
+ int64_t blocks_pos, end_of_indices;
+
+ char write_index = 1;
+ char iterate_block = 1;
+
+ av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries.\n",
+ num_streams, num_entries);
+
+ ff_put_guid(pb, &ff_asf_index_header);
+ avio_wl64(pb, 34 + 4 * num_streams + 4 + 8 * num_streams + 4 * num_entries*num_streams);
+ avio_wl32(pb, ASF_INDEX_ENTRY_TIME_INTERVAL); // interval
+ avio_wl16(pb, num_streams); // specifiers count
+
+ blocks_pos = avio_tell(pb);
+ avio_wl32(pb, 0); // rewrite later
+
+ // write specifiers
+ for (i = 0; i < num_streams; i++) {
+ avio_wl16(pb, i + 1);
+ avio_wl16(pb, SPECIFIER_INDEX_TYPE);
+ }
+
+ avio_wl32(pb, num_entries); // Index Entry Count
+
+ for (i = 0; write_index && i < num_entries; ++i) {
+
+ // block header
+ if (iterate_block) {
+ ++num_blocks;
+
+ for (j = 0; j < num_streams; ++j) {
+ avio_wl64(pb, 0);
+ }
+ iterate_block = 0;
+ }
+
+ // block content
+ for (j = 0; j < num_streams; ++j) {
+ ASFIndexData *idx = &(streams[j].idx_data);
+ uint32_t offset = INVALID_OFFSET;
+ if (i < idx->indices_count) {
+ uint64_t full_offset = idx->indices[i].offset;
+ offset = (uint32_t)full_offset & OFFSET_PART;
+ iterate_block = should_iterate_block(i, idx, full_offset);
+ }
+ else {
+ write_index = 0;
+ offset = INVALID_OFFSET;
+ av_log(s, AV_LOG_WARNING, "Index: invalid offset (%d,%d)\n", i, j);
+ }
+ avio_wl32(pb, offset);
+ }
+ }
+
+ end_of_indices = avio_tell(pb);
+
+ // rewrite blocks count and return file descriptor to end
+ avio_seek(pb, blocks_pos, SEEK_SET);
+ avio_wl32(pb, num_blocks);
+ avio_seek(pb, end_of_indices, SEEK_SET);
+
+ av_log(s, AV_LOG_DEBUG, "Write Index object for %d streams with %d entries done.\n",
+ num_streams, num_entries);
+
+ return 0;
}
diff --git a/libavformat/asf_trim.h b/libavformat/asf_trim.h
index 506b2f8..ddef614 100644
--- a/libavformat/asf_trim.h
+++ b/libavformat/asf_trim.h
@@ -1,4 +1,8 @@
/*
+ * @file asf_trim.c
+ * Extensions to ASF handling
+ * @author Vadim Belov
+ *
* Copyright (c) 2015 Vadim Belov
*
* This file is part of FFmpeg.
@@ -36,10 +40,10 @@ int asf_get_streams_direction(AVFormatContext *s);
* Set stream direction attributes in output ASF file
*/
void set_stream_direction(
- AVFormatContext *s,
- int direction[ASF_MAX_STREAMS_NUM],
- AVStream *st,
- int i);
+ AVFormatContext *s,
+ int direction[ASF_MAX_STREAMS_NUM],
+ AVStream *st,
+ int i);
/**
@@ -48,17 +52,17 @@ void set_stream_direction(
* @return error code: 0 iff success
*/
int asf_alloc_streams_index(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams,
- int block_size);
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams,
+ int block_size);
/**
* Free index object for a stream
*/
void asf_free_streams_index(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams);
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams);
/**
@@ -69,13 +73,13 @@ void asf_free_streams_index(
* @return error code: 0 iff success
*/
int upadte_indices(
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- uint64_t pkt_time,
- uint64_t packet_offset,
- int stream_index,
- int64_t pkt_duration,
- uint32_t asf_index_block,
- uint64_t asf_data_start);
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ uint64_t pkt_time,
+ uint64_t packet_offset,
+ int stream_index,
+ int64_t pkt_duration,
+ uint32_t asf_index_block,
+ uint64_t asf_data_start);
/**
@@ -84,8 +88,8 @@ int upadte_indices(
* @return error code: 0 iff success
*/
int asf_write_indices(
- AVFormatContext *s,
- ASFStream streams[ASF_MAX_STREAMS_NUM],
- int num_streams);
+ AVFormatContext *s,
+ ASFStream streams[ASF_MAX_STREAMS_NUM],
+ int num_streams);
#endif /* ASF_TRIM_H */
diff --git a/libavformat/asfdec.c b/libavformat/asfdec.c
index 826b80f..28b429a 100644
--- a/libavformat/asfdec.c
+++ b/libavformat/asfdec.c
@@ -83,7 +83,7 @@ typedef struct ASFContext {
int no_resync_search;
int export_xmp;
- int direction[ASF_MAX_STREAMS_NUM];
+ int direction[ASF_MAX_STREAMS_NUM];
} ASFContext;
static const AVOption options[] = {
@@ -675,8 +675,8 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
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;
-
+ 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)
@@ -686,14 +686,14 @@ static int asf_read_metadata(AVFormatContext *s, int64_t size)
if(stream_num < 128)
asf->dar[stream_num].den = aspect_y;
} else if(!strcmp(name, STREAM_DIRECTION_STR) &&
- 0 < stream_num && stream_num < 128){
- int direction = get_value(s->pb, value_type, value_len);
-
- av_log(s, AV_LOG_DEBUG, "stream %d Direction is %d\n",
+ 0 < stream_num && stream_num < 128){
+ int direction = get_value(s->pb, value_type, value_len);
+
+ av_log(s, AV_LOG_DEBUG, "stream %d Direction is %d\n",
stream_num, direction);
-
- asf->direction[stream_num] = direction;
- } else {
+
+ asf->direction[stream_num] = direction;
+ } else {
get_tag(s, name, value_type, value_len, 16);
}
}
@@ -868,8 +868,8 @@ static int asf_read_header(AVFormatContext *s)
&st->sample_aspect_ratio.den,
asf->dar[0].num, asf->dar[0].den, INT_MAX);
- set_stream_direction(s, asf->direction, st, i);
-
+ set_stream_direction(s, asf->direction, st, i);
+
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 a554da5..782c5cc 100644
--- a/libavformat/asfenc.c
+++ b/libavformat/asfenc.c
@@ -220,9 +220,12 @@ static const AVCodecTag codec_asf_bmp_tags[] = {
{ AV_CODEC_ID_NONE, 0 },
};
-// Preroll must be 0 in order to be consistent with player
+/**
+ * Preroll must be 0 in order to be consistent with player
+ * instead of:
+ * #define PREROLL_TIME 3100
+ */
#define PREROLL_TIME 0
-//#define PREROLL_TIME 3100
static void put_str16(AVIOContext *s, const char *tag)
{
@@ -354,7 +357,7 @@ 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 has_direction = 0;
+ int has_direction = 0;
int metadata_count;
AVCodecContext *enc;
int64_t header_offset, cur_pos, hpos;
@@ -385,8 +388,8 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
&& enc->sample_aspect_ratio.den > 0)
has_aspect_ratio++;
}
-
- has_direction = asf_get_streams_direction(s);
+
+ has_direction = asf_get_streams_direction(s);
if (asf->is_streamed) {
put_chunk(s, 0x4824, 0, 0xc00); /* start of stream (length will be patched later) */
@@ -419,36 +422,36 @@ static int asf_write_header1(AVFormatContext *s, int64_t file_size,
hpos = put_header(pb, &ff_asf_head1_guid);
ff_put_guid(pb, &ff_asf_head2_guid);
avio_wl16(pb, 6);
-
- if (has_direction) {
- int64_t hpos2;
- avio_wl32(pb, 26 + has_direction * 46);
- hpos2 = put_header(pb, &ff_asf_metadata_header);
- avio_wl16(pb, has_direction);
- for (n = 0; n < s->nb_streams; n++) {
- int streamId;
- int direction;
-
- AVDictionaryEntry *t = av_dict_get(
- s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
-
- sscanf(t->value, "%d %d", &streamId, &direction);
-
- av_log(s, AV_LOG_DEBUG, "Writing stream[%d] direction of stream %d, (%d)\n",
- n + 1, streamId, direction);
-
- avio_wl16(pb, 0); // Reserved
- avio_wl16(pb, streamId);// Stream Number
- avio_wl16(pb, 32); // Name Length
- avio_wl16(pb, 5); // Data Type
- avio_wl32(pb, 2); // Data Length
- avio_put_str16le(pb, STREAM_DIRECTION_STR); // 32
- avio_wl16(pb, direction);
- }
- end_header(pb, hpos2);
+
+ if (has_direction) {
+ int64_t hpos2;
+ avio_wl32(pb, 26 + has_direction * 46);
+ hpos2 = put_header(pb, &ff_asf_metadata_header);
+ avio_wl16(pb, has_direction);
+ for (n = 0; n < s->nb_streams; n++) {
+ int streamId;
+ int direction;
+
+ AVDictionaryEntry *t = av_dict_get(
+ s->streams[n]->metadata, DIRECTION_DICT_KEY, NULL, 0);
+
+ sscanf(t->value, "%d %d", &streamId, &direction);
+
+ av_log(s, AV_LOG_DEBUG, "Writing stream[%d] direction of stream %d, (%d)\n",
+ n + 1, streamId, direction);
+
+ avio_wl16(pb, 0); // Reserved
+ avio_wl16(pb, streamId);// Stream Number
+ avio_wl16(pb, 32); // Name Length
+ avio_wl16(pb, 5); // Data Type
+ avio_wl32(pb, 2); // Data Length
+ avio_put_str16le(pb, STREAM_DIRECTION_STR); // 32
+ avio_wl16(pb, direction);
+ }
+ end_header(pb, hpos2);
} else if (has_aspect_ratio) {
-
+
int64_t hpos2;
avio_wl32(pb, 26 + has_aspect_ratio * 84);
hpos2 = put_header(pb, &ff_asf_metadata_header);
@@ -693,16 +696,16 @@ static int asf_write_header(AVFormatContext *s)
asf->nb_index_memory_alloc = ASF_INDEX_BLOCK;
asf->maximum_packet = 0;
- if (asf_alloc_streams_index(asf->streams, s->nb_streams, ASF_INDEX_BLOCK)
- != 0) return -1;
-
+ if (asf_alloc_streams_index(asf->streams, s->nb_streams, ASF_INDEX_BLOCK)
+ != 0) return -1;
+
/* the data-chunk-size has to be 50 (DATA_HEADER_SIZE), which is
* data_size - asf->data_offset at the moment this function is done.
* It is needed to use asf as a streamable format. */
if (asf_write_header1(s, 0, DATA_HEADER_SIZE) < 0) {
//av_free(asf);
av_freep(&asf->index_ptr);
- asf_free_streams_index(asf->streams, s->nb_streams);
+ asf_free_streams_index(asf->streams, s->nb_streams);
return -1;
}
@@ -985,17 +988,17 @@ static int asf_write_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
}
asf->end_sec = start_sec;
-
- ret = upadte_indices(
- asf->streams,
- pts,
- offset,
- pkt->stream_index,
- pkt->duration,
- ASF_INDEX_BLOCK,
- asf->data_offset + DATA_HEADER_SIZE);
- if (ret < 0) return ret;
-
+
+ ret = upadte_indices(
+ asf->streams,
+ pts,
+ offset,
+ pkt->stream_index,
+ pkt->duration,
+ ASF_INDEX_BLOCK,
+ asf->data_offset + DATA_HEADER_SIZE);
+ if (ret < 0) return ret;
+
return 0;
}
@@ -1038,8 +1041,8 @@ static int asf_write_trailer(AVFormatContext *s)
}
avio_flush(s->pb);
- /* write indices with duration */
- asf_write_indices(s, asf->streams, s->nb_streams);
+ /* write indices with duration */
+ asf_write_indices(s, asf->streams, s->nb_streams);
avio_flush(s->pb);
if (asf->is_streamed || !s->pb->seekable) {
@@ -1051,7 +1054,7 @@ static int asf_write_trailer(AVFormatContext *s)
asf_write_header1(s, file_size, data_size - asf->data_offset);
}
- asf_free_streams_index(asf->streams, s->nb_streams);
+ asf_free_streams_index(asf->streams, s->nb_streams);
av_freep(&asf->index_ptr);
return 0;
}
diff --git a/libavformat/concatdec.c b/libavformat/concatdec.c
index c61d5c2..a66035b 100644
--- a/libavformat/concatdec.c
+++ b/libavformat/concatdec.c
@@ -172,7 +172,7 @@ static int copy_stream_props(AVStream *st, AVStream *source_st)
st->avg_frame_rate = source_st->avg_frame_rate;
st->time_base = source_st->time_base;
st->sample_aspect_ratio = source_st->sample_aspect_ratio;
-
+
av_dict_copy(&st->metadata, source_st->metadata, 0);
return 0;
}
--
1.9.5.msysgit.1
More information about the ffmpeg-devel
mailing list