Commit 2fbe43a5 authored by François Grisez's avatar François Grisez
Browse files

Make the h264 decoder to clean its context when the MKV player seek for another position

parent cc406f94
......@@ -265,6 +265,15 @@ static void dec_process(MSFilter *f){
ms_queue_init(&nalus);
while((im=ms_queue_get(f->inputs[0]))!=NULL){
// Reset all contexts when an empty packet is received
if(msgdsize(im) == 0) {
rfc3984_uninit(&d->unpacker);
rfc3984_init(&d->unpacker);
dec_reinit(d);
ms_stream_regulator_reset(d->regulator);
freemsg(im);
continue;
}
/*push the sps/pps given in sprop-parameter-sets if any*/
if (d->packet_num==0 && d->sps && d->pps){
mblk_set_timestamp_info(d->sps,mblk_get_timestamp_info(im));
......
......@@ -2064,6 +2064,14 @@ static MKVBlockGroupMaker *mkv_block_group_maker_new(MKVTrackReader *t_reader) {
return obj;
}
static void mkv_block_group_maker_reset(MKVBlockGroupMaker *obj) {
mkv_block_queue_flush(obj->queue);
mkv_block_free(obj->waiting_block);
obj->waiting_block = NULL;
obj->prev_timestamp = -1;
obj->prev_min_ts = 0;
}
static void mkv_block_group_maker_free(MKVBlockGroupMaker *obj) {
mkv_block_queue_free(obj->queue);
if(obj->waiting_block) mkv_block_free(obj->waiting_block);
......@@ -2077,7 +2085,7 @@ static void mkv_block_group_maker_get_next_group(MKVBlockGroupMaker *obj, MKVBlo
mkv_track_reader_next_block(obj->track_reader, &block, &_eot);
if(_eot) {
*eot = TRUE;
mkv_block_queue_push(out_queue, obj->waiting_block);
if(obj->waiting_block) mkv_block_queue_push(out_queue, obj->waiting_block);
obj->waiting_block = NULL;
return;
}
......@@ -2159,11 +2167,19 @@ static void mkv_track_player_send_block(MKVTrackPlayer *obj, const MKVBlock *blo
}
}
static void mkv_track_player_reset(MKVTrackPlayer *obj) {
obj->first_frame = TRUE;
mkv_block_queue_flush(obj->block_queue);
mkv_block_group_maker_reset(obj->group_maker);
obj->eot = FALSE;
}
typedef struct {
MKVReader *reader;
MSPlayerState state;
timecode_t time;
MKVTrackPlayer *players[2];
ms_bool_t position_changed;
} MKVPlayer;
static int player_close(MSFilter *f, void *arg);
......@@ -2247,6 +2263,14 @@ static void player_process(MSFilter *f) {
if(obj->state == MSPlayerPlaying) {
obj->time += f->ticker->interval;
if(obj->position_changed) {
for(i=0; i<2; i++) {
if(obj->players[i]) mkv_track_player_reset(obj->players[i]);
}
ms_queue_put(f->outputs[0], allocb(0, 0));
obj->position_changed = FALSE;
}
for(i=0; i<2; i++) {
MKVTrackPlayer *t_player = obj->players[i];
if(t_player && f->outputs[i]) {
......@@ -2300,6 +2324,7 @@ static int player_seek_ms(MSFilter *f, void *arg) {
goto fail;
}
obj->time = mkv_reader_seek(obj->reader, target_position);
obj->position_changed = TRUE;
ms_filter_unlock(f);
return 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment