~ubuntu-branches/ubuntu/utopic/libav/utopic-proposed

« back to all changes in this revision

Viewing changes to libavformat/nutenc.c

  • Committer: Package Import Robot
  • Author(s): Reinhard Tartler, Reinhard Tartler, Rico Tzschichholz
  • Date: 2014-08-30 11:02:45 UTC
  • mfrom: (1.3.47 sid)
  • Revision ID: package-import@ubuntu.com-20140830110245-io3dg7q85wfr7125
Tags: 6:11~beta1-2
[ Reinhard Tartler ]
* Make libavcodec-dev depend on libavresample-dev

[ Rico Tzschichholz ]
* Some fixes and leftovers from soname bumps

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
#include "libavutil/mathematics.h"
26
26
#include "libavutil/tree.h"
27
27
#include "libavutil/dict.h"
 
28
#include "libavutil/time.h"
 
29
#include "libavutil/opt.h"
28
30
#include "libavcodec/mpegaudiodata.h"
29
31
#include "nut.h"
30
32
#include "internal.h"
325
327
        tmp_head_idx;
326
328
    int64_t tmp_match;
327
329
 
328
 
    ff_put_v(bc, NUT_VERSION);
 
330
    ff_put_v(bc, nut->version);
329
331
    ff_put_v(bc, nut->avf->nb_streams);
330
332
    ff_put_v(bc, nut->max_distance);
331
333
    ff_put_v(bc, nut->time_base_count);
405
407
        ff_put_v(bc, nut->header_len[i]);
406
408
        avio_write(bc, nut->header[i], nut->header_len[i]);
407
409
    }
 
410
    // flags had been effectively introduced in version 4
 
411
    if (nut->version > NUT_STABLE_VERSION)
 
412
        ff_put_v(bc, nut->flags);
408
413
}
409
414
 
410
415
static int write_streamheader(AVFormatContext *avctx, AVIOContext *bc,
643
648
 
644
649
    nut->avf = s;
645
650
 
 
651
    nut->version = NUT_STABLE_VERSION + !!nut->flags;
 
652
    if (nut->flags && s->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL) {
 
653
        av_log(s, AV_LOG_ERROR,
 
654
               "The additional syncpoint modes require version %d, "
 
655
               "that is currently not finalized, "
 
656
               "please set -f_strict experimental in order to enable it.\n",
 
657
               nut->version);
 
658
        return AVERROR_EXPERIMENTAL;
 
659
    }
 
660
 
646
661
    nut->stream = av_mallocz(sizeof(StreamContext) * s->nb_streams);
647
662
    if (s->nb_chapters)
648
663
        nut->chapter = av_mallocz(sizeof(ChapterContext) * s->nb_chapters);
659
674
        AVStream *st = s->streams[i];
660
675
        int ssize;
661
676
        AVRational time_base;
662
 
        ff_parse_specific_params(st->codec, &time_base.den, &ssize,
 
677
        ff_parse_specific_params(st, &time_base.den, &ssize,
663
678
                                 &time_base.num);
664
679
 
665
680
        avpriv_set_pts_info(st, 64, time_base.num, time_base.den);
789
804
 
790
805
//FIXME: Ensure store_sp is 1 in the first place.
791
806
 
792
 
    if (store_sp) {
 
807
    if (store_sp &&
 
808
        (!(nut->flags & NUT_PIPE) || nut->last_syncpoint_pos == INT_MIN)) {
793
809
        Syncpoint *sp, dummy = { .pos = INT64_MAX };
794
810
 
795
811
        ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
815
831
            return ret;
816
832
        put_tt(nut, nus->time_base, dyn_bc, pkt->dts);
817
833
        ff_put_v(dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos) >> 4 : 0);
 
834
 
 
835
        if (nut->flags & NUT_BROADCAST) {
 
836
            put_tt(nut, nus->time_base, dyn_bc,
 
837
                   av_rescale_q(av_gettime(), AV_TIME_BASE_Q, *nus->time_base));
 
838
        }
818
839
        put_packet(nut, bc, dyn_bc, 1, SYNCPOINT_STARTCODE);
819
840
 
820
841
        if ((ret = ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0 /*unused*/, pkt->dts)) < 0)
917
938
    nus->last_pts   = pkt->pts;
918
939
 
919
940
    //FIXME just store one per syncpoint
920
 
    if (flags & FLAG_KEY)
 
941
    if (flags & FLAG_KEY && !(nut->flags & NUT_PIPE))
921
942
        av_add_index_entry(
922
943
            s->streams[pkt->stream_index],
923
944
            nut->last_syncpoint_pos,
945
966
    return 0;
946
967
}
947
968
 
 
969
#define OFFSET(x) offsetof(NUTContext, x)
 
970
#define E AV_OPT_FLAG_ENCODING_PARAM
 
971
static const AVOption options[] = {
 
972
    { "syncpoints",  "NUT syncpoint behaviour",                         OFFSET(flags), AV_OPT_TYPE_FLAGS, {.i64 = 0},             INT_MIN, INT_MAX, E, "syncpoints" },
 
973
    { "default",     "",                                                0,             AV_OPT_TYPE_CONST, {.i64 = 0},             INT_MIN, INT_MAX, E, "syncpoints" },
 
974
    { "none",        "Disable syncpoints, low overhead and unseekable", 0,             AV_OPT_TYPE_CONST, {.i64 = NUT_PIPE},      INT_MIN, INT_MAX, E, "syncpoints" },
 
975
    { "timestamped", "Extend syncpoints with a wallclock timestamp",    0,             AV_OPT_TYPE_CONST, {.i64 = NUT_BROADCAST}, INT_MIN, INT_MAX, E, "syncpoints" },
 
976
    { NULL },
 
977
};
 
978
 
 
979
static const AVClass class = {
 
980
    .class_name = "nutenc",
 
981
    .item_name  = av_default_item_name,
 
982
    .option     = options,
 
983
    .version    = LIBAVUTIL_VERSION_INT,
 
984
};
 
985
 
948
986
AVOutputFormat ff_nut_muxer = {
949
987
    .name           = "nut",
950
988
    .long_name      = NULL_IF_CONFIG_SMALL("NUT"),
959
997
    .write_trailer  = nut_write_trailer,
960
998
    .flags          = AVFMT_GLOBALHEADER | AVFMT_VARIABLE_FPS,
961
999
    .codec_tag      = ff_nut_codec_tags,
 
1000
    .priv_class     = &class,
962
1001
};