diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /ffmpeg/libavformat/nutenc.c | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'ffmpeg/libavformat/nutenc.c')
| -rw-r--r-- | ffmpeg/libavformat/nutenc.c | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/ffmpeg/libavformat/nutenc.c b/ffmpeg/libavformat/nutenc.c index 2d8d265..107e57b 100644 --- a/ffmpeg/libavformat/nutenc.c +++ b/ffmpeg/libavformat/nutenc.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include <stdint.h> + #include "libavutil/intreadwrite.h" #include "libavutil/mathematics.h" #include "libavutil/tree.h" @@ -91,7 +93,7 @@ static int find_expected_header(AVCodecContext *c, int size, int key_frame, header |= (bitrate_index & 1) << 9; return 2; //FIXME actually put the needed ones in build_elision_headers() - return 3; //we guess that the private bit is not set + //return 3; //we guess that the private bit is not set //FIXME the above assumptions should be checked, if these turn out false too often something should be done } return 0; @@ -335,7 +337,9 @@ static void write_mainheader(NUTContext *nut, AVIOContext *bc) tmp_head_idx; int64_t tmp_match; - ff_put_v(bc, 3); /* version */ + ff_put_v(bc, nut->version = NUT_VERSION); + if (nut->version > 3) + ff_put_v(bc, nut->minor_version); ff_put_v(bc, nut->avf->nb_streams); ff_put_v(bc, nut->max_distance); ff_put_v(bc, nut->time_base_count); @@ -584,8 +588,15 @@ static int write_index(NUTContext *nut, AVIOContext *bc) { int64_t last_pts= -1; int j, k; for (j=0; j<nut->sp_count; j++) { - int flag = (nus->keyframe_pts[j] != AV_NOPTS_VALUE) ^ (j+1 == nut->sp_count); + int flag; int n = 0; + + if (j && nus->keyframe_pts[j] == nus->keyframe_pts[j-1]) { + av_log(nut->avf, AV_LOG_WARNING, "Multiple keyframes with same PTS\n"); + nus->keyframe_pts[j] = AV_NOPTS_VALUE; + } + + flag = (nus->keyframe_pts[j] != AV_NOPTS_VALUE) ^ (j+1 == nut->sp_count); for (; j<nut->sp_count && (nus->keyframe_pts[j] != AV_NOPTS_VALUE) == flag; j++) n++; @@ -680,10 +691,10 @@ static int nut_write_header(AVFormatContext *s) nut->avf = s; - nut->stream = av_mallocz(sizeof(StreamContext ) * s->nb_streams); - nut->chapter = av_mallocz(sizeof(ChapterContext) * s->nb_chapters); - nut->time_base= av_mallocz(sizeof(AVRational ) *(s->nb_streams + - s->nb_chapters)); + nut->stream = av_calloc(s->nb_streams, sizeof(*nut->stream )); + nut->chapter = av_calloc(s->nb_chapters, sizeof(*nut->chapter)); + nut->time_base= av_calloc(s->nb_streams + + s->nb_chapters, sizeof(*nut->time_base)); if (!nut->stream || !nut->chapter || !nut->time_base) { av_freep(&nut->stream); av_freep(&nut->chapter); @@ -858,13 +869,14 @@ static int nut_write_packet(AVFormatContext *s, AVPacket *pkt) ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos) >> 4 : 0); put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE); - ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts); + if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0) + return ret; if ((1ll<<60) % nut->sp_count == 0) for (i=0; i<s->nb_streams; i++) { int j; StreamContext *nus = &nut->stream[i]; - nus->keyframe_pts = av_realloc(nus->keyframe_pts, 2*nut->sp_count*sizeof(*nus->keyframe_pts)); + av_reallocp_array(&nus->keyframe_pts, 2*nut->sp_count, sizeof(*nus->keyframe_pts)); if (!nus->keyframe_pts) return AVERROR(ENOMEM); for (j=nut->sp_count == 1 ? 0 : nut->sp_count; j<2*nut->sp_count; j++) |
