/* * mpeg-pes interface */ #define MAX_STC_DTS_DIFF (INT64_C(90000 * 30)) /* 30 seconds */ static int graphics_processor_decode_pes(PG_DISPLAY_SET **s, PES_BUFFER **p, int64_t stc) { if (!s) { return 0; } if (*s == NULL) { *s = calloc(1, sizeof(PG_DISPLAY_SET)); } while (*p) { /* time to decode next segment ? */ if (stc >= 0 && (*p)->dts > stc) { /* filter out values that seem to be incorrect (if stc is not updated) */ int64_t diff = (*p)->dts - stc; if (diff < MAX_STC_DTS_DIFF) { GP_TRACE("Segment dts > stc (%"PRId64" > %"PRId64" ; diff %"PRId64")\n", (*p)->dts, stc, diff); return 0; } } /* all fragments present ? */ if (!_join_segment_fragments(*p)) { GP_TRACE("splitted segment not complete, waiting for next fragment\n"); return 0; } if ((*p)->len <= 2) { BD_DEBUG(DBG_DECODE, "segment too short, skipping (%d bytes)\n", (*p)->len); pes_buffer_remove(p, *p); continue; } /* decode segment */ GP_TRACE("Decoding segment, dts %010"PRId64" pts %010"PRId64" len %d\n", (*p)->dts, (*p)->pts, (*p)->len); (*s)->complete = 0; _decode_segment(*s, *p); pes_buffer_remove(p, *p); if ((*s)->complete) { return 1; } } return 0; }
int graphics_processor_decode_pes(PG_DISPLAY_SET **s, PES_BUFFER **p, int64_t stc) { if (!s) { return 0; } if (*s == NULL) { *s = calloc(1, sizeof(PG_DISPLAY_SET)); } (*s)->complete = 0; while (*p && !(*s)->complete) { /* time to decode next segment ? */ if (stc >= 0 && (*p)->dts > stc) { GP_TRACE("Segment dts > stc (%"PRId64" > %"PRId64" ; diff %"PRId64")\n", (*p)->dts, stc, (*p)->dts - stc); return 0; } /* all fragments present ? */ if (!_join_segment_fragments(*p)) { GP_TRACE("splitted segment not complete, waiting for next fragment\n"); return 0; } GP_TRACE("Decoding segment, dts %010"PRId64" pts %010"PRId64" len %d\n", (*p)->dts, (*p)->pts, (*p)->len); /* decode segment */ if ((*p)->len > 2) { _decode_segment(*s, *p); } pes_buffer_remove(p, *p); } return (*s)->complete; }