Revision 20121213

View differences:

libavformat/gxfenc.c
572 572
    return updatePacketSize(pb, pos);
573 573
}
574 574

  
575
#define GXF_NODELAY -5000
576

  
575 577
static int gxf_write_header(AVFormatContext *s)
576 578
{
577 579
    ByteIOContext *pb = &s->pb;
......
623 625
                gxf->flags |= 0x00000040;
624 626
            }
625 627
            gxf->sample_rate = sc->sample_rate;
626
            av_set_pts_info(st, 64, 1, sc->sample_rate);
628
            av_set_pts_info(st, 64, 1, st->codec->time_base.den);
629
            sc->dts_delay = GXF_NODELAY;
627 630
            if (gxf_find_lines_index(sc) < 0)
628 631
                sc->lines_index = -1;
629 632
            sc->sample_size = st->codec->bit_rate;
......
707 710
static int gxf_write_media_preamble(ByteIOContext *pb, GXFContext *ctx, AVPacket *pkt, int size)
708 711
{
709 712
    GXFStreamContext *sc = &ctx->streams[pkt->stream_index];
710
    int64_t dts = av_rescale(pkt->dts, ctx->sample_rate, sc->sample_rate);
713
    int64_t dts = av_rescale(pkt->dts, ctx->sample_rate, sc->codec->time_base.den);
711 714

  
712 715
    put_byte(pb, sc->media_type);
713 716
    put_byte(pb, sc->index);
......
799 802
                    break; /* add pkt right now into list */
800 803
                }
801 804
            }
802
        } else if (pkt) {
803
            /* adjust dts if negative */
804
            if (pkt->dts < 0 && !sc->dts_delay) {
805
                /* XXX: rescale if codec time base is different from stream time base */
806
                sc->dts_delay = av_rescale_q(pkt->dts, st->codec->time_base, st->time_base);
807
                pkt->dts = sc->dts_delay; /* set to 0 */
808
            }
805
        } else if (pkt && pkt->stream_index == i) {
806
            if (sc->dts_delay == GXF_NODELAY) /* adjust dts if needed */
807
                sc->dts_delay = pkt->dts;
809 808
            pkt->dts -= sc->dts_delay;
810 809
        }
811 810
    }

Also available in: Unified diff