comparison nutenc.c @ 2350:a0fb5ef1ec7c libavformat

set back ptr properly
author michael
date Thu, 09 Aug 2007 23:29:58 +0000
parents 5c32dd0eafc6
children 0bf0afe32fcc
comparison
equal deleted inserted replaced
2349:a9dc7596498a 2350:a0fb5ef1ec7c
18 * License along with FFmpeg; if not, write to the Free Software 18 * License along with FFmpeg; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */ 20 */
21 21
22 #include "nut.h" 22 #include "nut.h"
23 #include "tree.h"
23 24
24 #define TRACE 25 #define TRACE
25 26
26 static void build_frame_code(AVFormatContext *s){ 27 static void build_frame_code(AVFormatContext *s){
27 NUTContext *nut = s->priv_data; 28 NUTContext *nut = s->priv_data;
410 store_sp= 1; 411 store_sp= 1;
411 412
412 //FIXME ensure store_sp is 1 for the first thing 413 //FIXME ensure store_sp is 1 for the first thing
413 414
414 if(store_sp){ 415 if(store_sp){
416 syncpoint_t *sp, dummy= {.pos= INT64_MAX};
417
415 ff_nut_reset_ts(nut, *nus->time_base, pkt->dts); 418 ff_nut_reset_ts(nut, *nus->time_base, pkt->dts);
419 for(i=0; i<s->nb_streams; i++){
420 AVStream *st= s->streams[i];
421 int index= av_index_search_timestamp(st, pkt->dts, AVSEEK_FLAG_BACKWARD);
422 if(index<0) dummy.pos=0;
423 else dummy.pos= FFMIN(dummy.pos, st->index_entries[index].pos);
424 }
425 sp= av_tree_find(nut->syncpoints, &dummy, ff_nut_sp_pos_cmp, NULL);
416 426
417 nut->last_syncpoint_pos= url_ftell(bc); 427 nut->last_syncpoint_pos= url_ftell(bc);
418 url_open_dyn_buf(&dyn_bc); 428 url_open_dyn_buf(&dyn_bc);
419 put_t(nut, nus, &dyn_bc, pkt->dts); 429 put_t(nut, nus, &dyn_bc, pkt->dts);
420 put_v(&dyn_bc, 0); //FIXME back_ptr_div16 430 put_v(&dyn_bc, sp ? (nut->last_syncpoint_pos - sp->pos)>>4 : 0);
421 put_packet(nut, bc, &dyn_bc, 1, SYNCPOINT_STARTCODE); 431 put_packet(nut, bc, &dyn_bc, 1, SYNCPOINT_STARTCODE);
432
433 ff_nut_add_sp(nut, nut->last_syncpoint_pos, 0/*unused*/, pkt->dts);
422 } 434 }
423 assert(nus->last_pts != AV_NOPTS_VALUE); 435 assert(nus->last_pts != AV_NOPTS_VALUE);
424 436
425 coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1); 437 coded_pts = pkt->pts & ((1<<nus->msb_pts_shift)-1);
426 if(ff_lsb2full(nus, coded_pts) != pkt->pts) 438 if(ff_lsb2full(nus, coded_pts) != pkt->pts)
490 if(flags & FLAG_CHECKSUM) put_le32(bc, get_checksum(bc)); 502 if(flags & FLAG_CHECKSUM) put_le32(bc, get_checksum(bc));
491 else get_checksum(bc); 503 else get_checksum(bc);
492 504
493 put_buffer(bc, pkt->data, pkt->size); 505 put_buffer(bc, pkt->data, pkt->size);
494 nus->last_flags= flags; 506 nus->last_flags= flags;
507
508 //FIXME just store one per syncpoint
509 if(flags & FLAG_KEY)
510 av_add_index_entry(
511 s->streams[pkt->stream_index],
512 nut->last_syncpoint_pos,
513 pkt->pts,
514 0,
515 0,
516 AVINDEX_KEYFRAME);
517
495 return 0; 518 return 0;
496 } 519 }
497 520
498 static int write_trailer(AVFormatContext *s){ 521 static int write_trailer(AVFormatContext *s){
499 NUTContext *nut= s->priv_data; 522 NUTContext *nut= s->priv_data;