Commit b170af8a authored by Ghislain MARY's avatar Ghislain MARY

VP8 unpacker is now able to output full frames if the decoder does not support...

VP8 unpacker is now able to output full frames if the decoder does not support decoding partition by partition.
parent bd1d298a
......@@ -455,7 +455,7 @@ static void dec_init(MSFilter *f) {
if(vpx_codec_dec_init(&s->codec, iface, NULL, flags))
ms_error("Failed to initialize decoder");
vp8rtpfmt_unpacker_init(&s->unpacker, f);
vp8rtpfmt_unpacker_init(&s->unpacker, f, (flags & VPX_CODEC_USE_INPUT_FRAGMENTS) ? TRUE : FALSE);
s->curframe = NULL;
s->last_error_reported_time = 0;
s->yuv_width = 0;
......
......@@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
/*#define VP8RTPFMT_DEBUG*/
#define VP8RTPFMT_OUTPUT_INCOMPLETE_FRAMES
#ifdef VP8RTPFMT_DEBUG
......@@ -299,6 +298,27 @@ static void output_partition(MSQueue *out, Vp8RtpFmtPartition *partition) {
partition->outputted = TRUE;
}
static void output_frame(MSQueue *out, Vp8RtpFmtFrame *frame) {
Vp8RtpFmtPartition *partition;
int nb_partitions = ms_list_size(frame->partitions_list);
mblk_t *om;
mblk_t *curm;
int i;
for (i = 0; i < nb_partitions; i++) {
partition = ms_list_nth_data(frame->partitions_list, i);
if (i == 0) {
om = partition->m;
curm = om;
} else {
curm = concatb(curm, partition->m);
}
partition->outputted = TRUE;
}
mblk_set_marker_info(om, 1);
ms_queue_put(out, (void *)om);
}
static void output_valid_partitions(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out) {
Vp8RtpFmtPartition *partition = NULL;
Vp8RtpFmtFrame *frame;
......@@ -311,31 +331,36 @@ static void output_valid_partitions(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *out) {
frame = ms_list_nth_data(ctx->frames_list, i);
if (frame->error == Vp8RtpFmtOk) {
/* Output the complete valid frame. */
nb_partitions = ms_list_size(frame->partitions_list);
for (j = 0; j < nb_partitions; j++) {
partition = ms_list_nth_data(frame->partitions_list, j);
output_partition(out, partition);
if (ctx->output_partitions == TRUE) {
nb_partitions = ms_list_size(frame->partitions_list);
for (j = 0; j < nb_partitions; j++) {
partition = ms_list_nth_data(frame->partitions_list, j);
output_partition(out, partition);
}
} else {
/* Output the full frame in one mblk_t. */
output_frame(out, frame);
}
frame->outputted = TRUE;
} else if (is_frame_marker_present(frame) == TRUE) {
if (is_first_partition_present_in_frame(frame) == TRUE) {
#ifdef VP8RTPFMT_OUTPUT_INCOMPLETE_FRAMES
/* Output the valid partitions of the frame. */
nb_partitions = ms_list_size(frame->partitions_list);
for (i = 0; i < nb_partitions; i++) {
partition = ms_list_nth_data(frame->partitions_list, i);
if (partition->error == Vp8RtpFmtOk) {
if (i == (nb_partitions - 1)) {
partition->last_partition_of_frame = TRUE;
if (ctx->output_partitions == TRUE) {
/* Output the valid partitions of the frame. */
nb_partitions = ms_list_size(frame->partitions_list);
for (i = 0; i < nb_partitions; i++) {
partition = ms_list_nth_data(frame->partitions_list, i);
if (partition->error == Vp8RtpFmtOk) {
if (i == (nb_partitions - 1)) {
partition->last_partition_of_frame = TRUE;
}
output_partition(out, partition);
}
output_partition(out, partition);
}
frame->outputted = TRUE;
} else {
/* Drop the frame for which some partitions are missing/invalid. */
frame->discarded = TRUE;
}
frame->outputted = TRUE;
#else
/* Drop the frame for which some partitions are missing/invalid. */
frame->discarded = TRUE;
#endif
ms_filter_notify_no_arg(ctx->filter, MS_VIDEO_DECODER_SEND_PLI);
} else {
/* Drop the frame for which the first partition is missing. */
......@@ -450,8 +475,9 @@ static Vp8RtpFmtErrorCode parse_payload_descriptor(Vp8RtpFmtPacket *packet) {
}
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f) {
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f, bool_t output_partitions) {
ctx->filter = f;
ctx->output_partitions = output_partitions;
ctx->frames_list = NULL;
ms_queue_init(&ctx->output_queue);
ctx->initialized_last_ts = FALSE;
......
......@@ -90,6 +90,7 @@ extern "C"{
MSQueue output_queue;
uint32_t last_ts;
uint32_t ref_cseq;
bool_t output_partitions;
bool_t initialized_last_ts;
bool_t initialized_ref_cseq;
} Vp8RtpFmtUnpackerCtx;
......@@ -103,7 +104,7 @@ extern "C"{
void vp8rtpfmt_packer_uninit(Vp8RtpFmtPackerCtx *ctx);
void vp8rtpfmt_packer_process(Vp8RtpFmtPackerCtx *ctx, MSList *in, MSQueue *out);
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f);
void vp8rtpfmt_unpacker_init(Vp8RtpFmtUnpackerCtx *ctx, MSFilter *f, bool_t output_partitions);
void vp8rtpfmt_unpacker_uninit(Vp8RtpFmtUnpackerCtx *ctx);
void vp8rtpfmt_unpacker_process(Vp8RtpFmtUnpackerCtx *ctx, MSQueue *inout);
uint32_t vp8rtpfmt_unpacker_calc_extended_cseq(Vp8RtpFmtUnpackerCtx *ctx, uint16_t cseq);
......
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