Commit 3c79048f authored by Gautier Pelloux-Prayer's avatar Gautier Pelloux-Prayer
Browse files

dumb commit: remove vp8 decoder error logs

parent 028e6247
......@@ -22,23 +22,32 @@
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msticker.h"
#include "mediastreamer2/msvideo.h"
#include "mediastreamer2/videostarter.h"
#include "vp8rtpfmt.h"
#define VPX_CODEC_DISABLE_COMPAT 1
#include <vpx/vpx_encoder.h>
#include <vpx/vp8cx.h>
#undef interface
#define interface (vpx_codec_vp8_cx())
#define VP8_PAYLOAD_DESC_X_MASK 0x80
#define VP8_PAYLOAD_DESC_RSV_MASK 0x40
#define VP8_PAYLOAD_DESC_N_MASK 0x20
#define VP8_PAYLOAD_DESC_S_MASK 0x10
#define VP8_PAYLOAD_DESC_PARTID_MASK 0x0F
#undef FRAGMENT_ON_PARTITIONS
/*#define FRAGMENT_ON_PARTITIONS*/
#define MS_VP8_CONF(required_bitrate, bitrate_limit, resolution, fps) \
{ required_bitrate, bitrate_limit, { MS_VIDEO_SIZE_ ## resolution ## _W, MS_VIDEO_SIZE_ ## resolution ## _H }, fps, NULL }
static const MSVideoConfiguration vp8_conf_list[] = {
#if defined(ANDROID) || (TARGET_OS_IPHONE == 1) || defined(__arm__)
MS_VP8_CONF(300000, 600000, VGA, 12),
MS_VP8_CONF(100000, 300000, QVGA, 12),
MS_VP8_CONF( 64000, 100000, QCIF, 12),
MS_VP8_CONF( 0, 64000, QCIF, 5)
MS_VP8_CONF(300000, 600000, VGA, 12),
MS_VP8_CONF(100000, 300000, QVGA, 12),
MS_VP8_CONF( 64000, 100000, QCIF, 12),
MS_VP8_CONF( 0, 64000, QCIF, 5)
#else
MS_VP8_CONF(1024000, 1536000, VGA, 25),
MS_VP8_CONF( 350000, 600000, VGA, 15),
......@@ -74,73 +83,83 @@ static const MSVideoConfiguration multicore_vp8_conf_list[] = {
#endif
};
/* the goal of this small object is to tell when to send I frames at startup:
at 2 and 4 seconds*/
typedef struct VideoStarter{
uint64_t next_time;
int i_frame_count;
}VideoStarter;
static void video_starter_init(VideoStarter *vs){
vs->next_time=0;
vs->i_frame_count=0;
}
static void video_starter_first_frame(VideoStarter *vs, uint64_t curtime){
vs->next_time=curtime+2000;
}
static bool_t video_starter_need_i_frame(VideoStarter *vs, uint64_t curtime){
if (vs->next_time==0) return FALSE;
if (curtime>=vs->next_time){
vs->i_frame_count++;
if (vs->i_frame_count==1){
vs->next_time+=2000;
}else{
vs->next_time=0;
}
return TRUE;
}
return FALSE;
}
typedef struct EncState {
vpx_codec_ctx_t codec;
vpx_codec_enc_cfg_t cfg;
vpx_codec_pts_t frame_count;
vpx_codec_iface_t *iface;
vpx_codec_flags_t flags;
Vp8RtpFmtPackerCtx packer;
MSVideoStarter starter;
MSVideoConfiguration vconf;
const MSVideoConfiguration *vconf_list;
int last_fir_seq_nr;
uint8_t picture_id;
bool_t force_keyframe;
bool_t avpf_enabled;
long long frame_count;
unsigned int mtu;
VideoStarter starter;
bool_t req_vfu;
bool_t ready;
#ifdef FRAGMENT_ON_PARTITIONS
uint8_t token_partition_count;
#endif
const MSVideoConfiguration *vconf_list;
MSVideoConfiguration vconf;
} EncState;
static void vp8_fragment_and_send(MSFilter *f,EncState *s,mblk_t *frame, uint32_t timestamp, const vpx_codec_cx_pkt_t *pkt, bool_t lastPartition);
static void enc_init(MSFilter *f) {
EncState *s = (EncState *)ms_new0(EncState, 1);
vpx_codec_err_t res;
MSVideoSize vsize;
EncState *s=(EncState *)ms_new0(EncState,1);
ms_message("Using %s\n",vpx_codec_iface_name(interface));
s->iface = vpx_codec_vp8_cx();
ms_message("Using %s", vpx_codec_iface_name(s->iface));
/* Populate encoder configuration */
res = vpx_codec_enc_config_default(interface, &s->cfg, 0);
if(res) {
ms_error("Failed to get config: %s\n", vpx_codec_err_to_string(res));
}
if (ms_get_cpu_count() > 1) s->vconf_list = &multicore_vp8_conf_list[0];
else s->vconf_list = &vp8_conf_list[0];
MS_VIDEO_SIZE_ASSIGN(vsize, CIF);
s->vconf = ms_video_find_best_configuration_for_size(s->vconf_list, vsize);
s->frame_count = 0;
s->last_fir_seq_nr = -1;
s->picture_id = random() & 0x7F;
s->avpf_enabled = FALSE;
f->data = s;
}
static void enc_uninit(MSFilter *f) {
EncState *s = (EncState *)f->data;
ms_free(s);
}
static void enc_preprocess(MSFilter *f) {
EncState *s = (EncState *)f->data;
vpx_codec_err_t res;
vpx_codec_caps_t caps;
int cpuused;
/* Populate encoder configuration */
s->flags = 0;
caps = vpx_codec_get_caps(s->iface);
if ((s->avpf_enabled == TRUE) && (caps & VPX_CODEC_CAP_OUTPUT_PARTITION)) {
s->flags |= VPX_CODEC_USE_OUTPUT_PARTITION;
}
res = vpx_codec_enc_config_default(s->iface, &s->cfg, 0);
if (res) {
ms_error("Failed to get config: %s", vpx_codec_err_to_string(res));
return;
}
s->cfg.g_w = s->vconf.vsize.width;
s->cfg.g_h = s->vconf.vsize.height;
/* encoder automatically places keyframes */
s->cfg.kf_mode = VPX_KF_AUTO;
s->cfg.rc_target_bitrate = ((float)s->vconf.required_bitrate) * 0.92 / 1024.0; //0.9=take into account IP/UDP/RTP overhead, in average.
s->cfg.kf_max_dist = 300;
s->cfg.rc_target_bitrate = ((float)s->vconf.required_bitrate)*0.92/1024.0; //0.9=take into account IP/UDP/RTP overhead, in average.
s->cfg.g_pass = VPX_RC_ONE_PASS; /* -p 1 */
s->cfg.g_timebase.num = 1;
s->cfg.g_timebase.den = s->vconf.fps;
s->cfg.rc_end_usage = VPX_CBR; /* --end-usage=cbr */
#if TARGET_IPHONE_SIMULATOR
s->cfg.g_threads = 1; /*workaround to remove crash on ipad simulator*/
s->cfg.g_threads = 1; /*workaround to remove crash on ipad simulator*/
#else
s->cfg.g_threads = ms_get_cpu_count();
#endif
......@@ -148,124 +167,124 @@ static void enc_preprocess(MSFilter *f) {
s->cfg.rc_undershoot_pct = 95; /* --undershoot-pct=95 */
s->cfg.g_error_resilient = VPX_ERROR_RESILIENT_DEFAULT|VPX_ERROR_RESILIENT_PARTITIONS;
s->cfg.g_lag_in_frames = 0;
cpuused = 11 - s->cfg.g_threads; /*cpu/quality tradeoff: positive values decrease CPU usage at the expense of quality*/
if (cpuused < 7) cpuused = 7; /*values beneath 7 consume too much CPU*/
s->mtu=ms_get_payload_max_size()-1;/*-1 for the vp8 payload header*/
f->data = s;
}
static void enc_uninit(MSFilter *f) {
EncState *s=(EncState*)f->data;
ms_free(s);
}
static void enc_preprocess(MSFilter *f) {
vpx_codec_err_t res;
EncState *s=(EncState*)f->data;
s->cfg.g_w = s->vconf.vsize.width;
s->cfg.g_h = s->vconf.vsize.height;
s->cfg.g_timebase.den = s->vconf.fps;
s->cfg.kf_max_dist = (unsigned int)(s->vconf.fps * 10); /* 1 keyframe each 10s. */
s->cfg.g_timebase.den=s->vconf.fps;
/* Initialize codec */
res = vpx_codec_enc_init(&s->codec, s->iface, &s->cfg, s->flags);
#ifdef FRAGMENT_ON_PARTITIONS
/* VPX_CODEC_USE_OUTPUT_PARTITION: output 1 frame per partition */
res = vpx_codec_enc_init(&s->codec, interface, &s->cfg, VPX_CODEC_USE_OUTPUT_PARTITION);
#else
res = vpx_codec_enc_init(&s->codec, interface, &s->cfg, 0);
#endif
if (res) {
ms_error("vpx_codec_enc_init failed: %s (%s)", vpx_codec_err_to_string(res), vpx_codec_error_detail(&s->codec));
return;
ms_error("vpx_codec_enc_init failed: %s (%s)n", vpx_codec_err_to_string(res), vpx_codec_error_detail(&s->codec));
}
vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, cpuused);
/*cpu/quality tradeoff: positive values decrease CPU usage at the expense of quality*/
vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, (s->cfg.g_threads > 1) ? 10 : 10);
vpx_codec_control(&s->codec, VP8E_SET_STATIC_THRESHOLD, 0);
vpx_codec_control(&s->codec, VP8E_SET_ENABLEAUTOALTREF, 1);
vpx_codec_control(&s->codec, VP8E_SET_MAX_INTRA_BITRATE_PCT, 400); /*limite iFrame size to 4 pframe*/
if (s->flags & VPX_CODEC_USE_OUTPUT_PARTITION) {
vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 2); /* Output 4 partitions per frame */
} else {
vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 0);
}
vp8rtpfmt_packer_init(&s->packer);
if (s->avpf_enabled != TRUE) {
ms_video_starter_init(&s->starter);
#ifndef FRAGMENT_ON_PARTITIONS
if (s->cfg.g_threads > 1) {
if (vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 2) != VPX_CODEC_OK) {
ms_error("VP8: failed to set multiple token partition");
} else {
ms_message("VP8: multiple token partitions used");
}
}
s->ready = TRUE;
#endif
#ifdef FRAGMENT_ON_PARTITIONS
vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 0x3);
s->token_partition_count = 8;
#endif
/* vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, 0);*/ /* -16 (quality) .. 16 (speed) */
video_starter_init(&s->starter);
s->ready=TRUE;
}
static void enc_process(MSFilter *f) {
mblk_t *im;
uint64_t timems = f->ticker->time;
uint32_t timestamp = timems*90;
EncState *s = (EncState *)f->data;
mblk_t *im,*om;
uint64_t timems=f->ticker->time;
uint32_t timestamp=timems*90;
EncState *s=(EncState*)f->data;
unsigned int flags = 0;
vpx_codec_err_t err;
YuvBuf yuv;
ms_filter_lock(f);
if (!s->ready) {
while ((im = ms_queue_get(f->inputs[0])) != NULL) {
freemsg(im);
}
return;
}
while ((im = ms_queue_get(f->inputs[0])) != NULL) {
while((im=ms_queue_get(f->inputs[0]))!=NULL){
vpx_image_t img;
om = NULL;
flags = 0;
ms_yuv_buf_init_from_mblk(&yuv, im);
vpx_img_wrap(&img, VPX_IMG_FMT_I420, s->vconf.vsize.width, s->vconf.vsize.height, 1, yuv.planes[0]);
if ((s->avpf_enabled != TRUE) && ms_video_starter_need_i_frame(&s->starter, f->ticker->time)) {
s->force_keyframe = TRUE;
if (video_starter_need_i_frame (&s->starter,f->ticker->time)){
/*sends an I frame at 2 seconds and 4 seconds after the beginning of the call*/
s->req_vfu=TRUE;
}
if (s->force_keyframe == TRUE) {
ms_message("Forcing vp8 key frame for filter [%p]", f);
if (s->req_vfu){
ms_message("Forcing vp8 key frame for filter [%p]",f);
flags = VPX_EFLAG_FORCE_KF;
s->force_keyframe = FALSE;
s->req_vfu=FALSE;
}
err = vpx_codec_encode(&s->codec, &img, s->frame_count, 1, flags, VPX_DL_REALTIME);
if (err) {
ms_error("vpx_codec_encode failed : %d %s (%s)\n", err, vpx_codec_err_to_string(err), vpx_codec_error_detail(&s->codec));
} else {
vpx_codec_iter_t iter = NULL;
const vpx_codec_cx_pkt_t *pkt;
MSList *list = NULL;
s->frame_count++;
if ((s->avpf_enabled != TRUE) && (s->frame_count == 1)) {
ms_video_starter_first_frame(&s->starter, f->ticker->time);
if (s->frame_count==1){
video_starter_first_frame (&s->starter,f->ticker->time);
}
s->picture_id++;
if (s->picture_id == 0x80) s->picture_id = 0;
while( (pkt = vpx_codec_get_cx_data(&s->codec, &iter)) ) {
if ((pkt->kind == VPX_CODEC_CX_FRAME_PKT) && (pkt->data.frame.sz > 0)) {
Vp8RtpFmtPacket *packet = ms_new0(Vp8RtpFmtPacket, 1);
packet->m = allocb(pkt->data.frame.sz, 0);
memcpy(packet->m->b_wptr, pkt->data.frame.buf, pkt->data.frame.sz);
packet->m->b_wptr += pkt->data.frame.sz;
mblk_set_timestamp_info(packet->m, timestamp);
packet->pd = ms_new0(Vp8RtpFmtPayloadDescriptor, 1);
packet->pd->start_of_partition = TRUE;
if (pkt->data.frame.flags & VPX_FRAME_IS_DROPPABLE) {
packet->pd->non_reference_frame = TRUE;
if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
if (pkt->data.frame.sz > 0) {
om = allocb(pkt->data.frame.sz,0);
memcpy(om->b_wptr, pkt->data.frame.buf, pkt->data.frame.sz);
om->b_wptr += pkt->data.frame.sz;
#ifdef FRAGMENT_ON_PARTITIONS
vp8_fragment_and_send(f, s, om, timestamp, pkt, (pkt->data.frame.partition_id == s->token_partition_count));
#else
vp8_fragment_and_send(f, s, om, timestamp, pkt, 1);
#endif
}
packet->pd->extended_control_bits_present = TRUE;
packet->pd->pictureid_present = TRUE;
packet->pd->pictureid = s->picture_id;
if (s->flags & VPX_CODEC_USE_OUTPUT_PARTITION) {
packet->pd->pid = (uint8_t)pkt->data.frame.partition_id;
if (!(pkt->data.frame.flags & VPX_FRAME_IS_FRAGMENT)) {
mblk_set_marker_info(packet->m, TRUE);
}
} else {
packet->pd->pid = 0;
mblk_set_marker_info(packet->m, TRUE);
}
list = ms_list_append(list, packet);
}
}
vp8rtpfmt_packer_process(&s->packer, list, f->outputs[0]);
}
freemsg(im);
}
ms_filter_unlock(f);
}
static void enc_postprocess(MSFilter *f) {
EncState *s = (EncState *)f->data;
EncState *s=(EncState*)f->data;
if (s->ready) vpx_codec_destroy(&s->codec);
vp8rtpfmt_packer_uninit(&s->packer);
s->ready = FALSE;
s->ready=FALSE;
}
static int enc_set_configuration(MSFilter *f, void *data) {
......@@ -300,35 +319,41 @@ static int enc_set_vsize(MSFilter *f, void *data) {
return 0;
}
static int enc_get_vsize(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
MSVideoSize *vs = (MSVideoSize *)data;
static int enc_get_vsize(MSFilter *f, void *data){
EncState *s=(EncState*)f->data;
MSVideoSize *vs=(MSVideoSize*)data;
*vs = s->vconf.vsize;
return 0;
}
static int enc_set_fps(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
float *fps = (float *)data;
s->vconf.fps = *fps;
static int enc_add_attr(MSFilter *f, void*data){
/*const char *attr=(const char*)data;
EncState *s=(EncState*)f->data;*/
return 0;
}
static int enc_set_fps(MSFilter *f, void *data){
float *fps=(float*)data;
EncState *s=(EncState*)f->data;
s->vconf.fps=*fps;
enc_set_configuration(f, &s->vconf);
return 0;
}
static int enc_get_fps(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
float *fps = (float *)data;
*fps = s->vconf.fps;
static int enc_get_fps(MSFilter *f, void *data){
EncState *s=(EncState*)f->data;
float *fps=(float*)data;
*fps=s->vconf.fps;
return 0;
}
static int enc_get_br(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
*(int *)data = s->vconf.required_bitrate;
static int enc_get_br(MSFilter *f, void*data){
EncState *s=(EncState*)f->data;
*(int*)data=s->vconf.required_bitrate;
return 0;
}
static int enc_set_br(MSFilter *f, void *data) {
static int enc_set_br(MSFilter *f, void*data) {
EncState *s = (EncState *)f->data;
int br = *(int *)data;
if (s->ready) {
......@@ -342,25 +367,15 @@ static int enc_set_br(MSFilter *f, void *data) {
return 0;
}
static int enc_req_vfu(MSFilter *f, void *unused) {
EncState *s = (EncState *)f->data;
s->force_keyframe = TRUE;
static int enc_set_mtu(MSFilter *f, void*data){
EncState *s=(EncState*)f->data;
s->mtu=*(int*)data;
return 0;
}
static int enc_notify_pli(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
s->force_keyframe = TRUE;
return 0;
}
static int enc_notify_fir(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
uint8_t seq_nr = *((uint8_t *)data);
if (seq_nr != s->last_fir_seq_nr) {
s->force_keyframe = TRUE;
s->last_fir_seq_nr = seq_nr;
}
static int enc_req_vfu(MSFilter *f, void *unused){
EncState *s=(EncState*)f->data;
s->req_vfu=TRUE;
return 0;
}
......@@ -371,89 +386,125 @@ static int enc_get_configuration_list(MSFilter *f, void *data) {
return 0;
}
static int enc_enable_avpf(MSFilter *f, void *data) {
EncState *s = (EncState *)f->data;
s->avpf_enabled = *((bool_t *)data) ? TRUE : FALSE;
return 0;
}
static MSFilterMethod enc_methods[] = {
{ MS_FILTER_SET_VIDEO_SIZE, enc_set_vsize },
{ MS_FILTER_SET_FPS, enc_set_fps },
{ MS_FILTER_GET_VIDEO_SIZE, enc_get_vsize },
{ MS_FILTER_GET_FPS, enc_get_fps },
{ MS_FILTER_ADD_ATTR, enc_add_attr },
{ MS_FILTER_SET_BITRATE, enc_set_br },
{ MS_FILTER_GET_BITRATE, enc_get_br },
{ MS_FILTER_SET_MTU, enc_set_mtu },
{ MS_FILTER_REQ_VFU, enc_req_vfu },
{ MS_VIDEO_ENCODER_REQ_VFU, enc_req_vfu },
{ MS_VIDEO_ENCODER_NOTIFY_PLI, enc_notify_pli },
{ MS_VIDEO_ENCODER_NOTIFY_FIR, enc_notify_fir },
{ MS_VIDEO_ENCODER_GET_CONFIGURATION_LIST, enc_get_configuration_list },
{ MS_VIDEO_ENCODER_SET_CONFIGURATION, enc_set_configuration },
{ MS_VIDEO_ENCODER_ENABLE_AVPF, enc_enable_avpf },
{ 0, NULL }
};
#define MS_VP8_ENC_NAME "MSVp8Enc"
#define MS_VP8_ENC_DESCRIPTION "A VP8 video encoder using libvpx library."
#define MS_VP8_ENC_CATEGORY MS_FILTER_ENCODER
#define MS_VP8_ENC_ENC_FMT "VP8"
#define MS_VP8_ENC_NINPUTS 1 /*MS_YUV420P is assumed on this input */
#define MS_VP8_ENC_NOUTPUTS 1
#define MS_VP8_ENC_FLAGS 0
#ifdef _MSC_VER
MSFilterDesc ms_vp8_enc_desc = {
MSFilterDesc ms_vp8_enc_desc={
MS_VP8_ENC_ID,
MS_VP8_ENC_NAME,
MS_VP8_ENC_DESCRIPTION,
MS_VP8_ENC_CATEGORY,
MS_VP8_ENC_ENC_FMT,
MS_VP8_ENC_NINPUTS,
MS_VP8_ENC_NOUTPUTS,
"MSVp8Enc",
N_("A video VP8 encoder using libvpx library."),
MS_FILTER_ENCODER,
"VP8",
1, /*MS_YUV420P is assumed on this input */
1,
enc_init,
enc_preprocess,
enc_process,
enc_postprocess,
enc_uninit,
enc_methods,
MS_VP8_ENC_FLAGS
enc_methods
};
#else
MSFilterDesc ms_vp8_enc_desc = {
.id = MS_VP8_ENC_ID,
.name = MS_VP8_ENC_NAME,
.text = MS_VP8_ENC_DESCRIPTION,
.category = MS_VP8_ENC_CATEGORY,
.enc_fmt = MS_VP8_ENC_ENC_FMT,
.ninputs = MS_VP8_ENC_NINPUTS,
.noutputs = MS_VP8_ENC_NOUTPUTS,
.init = enc_init,
.preprocess = enc_preprocess,
.process = enc_process,
.postprocess = enc_postprocess,
.uninit = enc_uninit,
.methods = enc_methods,
.flags = MS_VP8_ENC_FLAGS
MSFilterDesc ms_vp8_enc_desc={
.id=MS_VP8_ENC_ID,
.name="MSVp8Enc",
.text=N_("A video VP8 encoder using libvpx library."),
.category=MS_FILTER_ENCODER,
.enc_fmt="VP8",
.ninputs=1, /*MS_YUV420P is assumed on this input */
.noutputs=1,
.init=enc_init,
.preprocess=enc_preprocess,
.process=enc_process,
.postprocess=enc_postprocess,
.uninit=enc_uninit,
.methods=enc_methods
};
#endif
MS_FILTER_DESC_EXPORT(ms_vp8_enc_desc)
static void vp8_fragment_and_send(MSFilter *f,EncState *s,mblk_t *frame, uint32_t timestamp, const vpx_codec_cx_pkt_t *pkt, bool_t lastPartition){
uint8_t *rptr;
mblk_t *packet=NULL;
mblk_t* vp8_payload_desc = NULL;
int len;
#if 0
if ((pkt->data.frame.flags & VPX_FRAME_IS_KEY) == 0) {
ms_debug("P-FRAME: %u\n", pkt->data.frame.sz);
} else {
ms_debug("I-FRAME: %u\n", pkt->data.frame.sz);
}
#endif
for (rptr=frame->b_rptr;rptr<frame->b_wptr;){
vp8_payload_desc = allocb(1, 0);
vp8_payload_desc->b_wptr=vp8_payload_desc->b_rptr+1;
len=MIN(s->mtu,(frame->b_wptr-rptr));
packet=dupb(frame);
packet->b_rptr=rptr;
packet->b_wptr=rptr+len;
mblk_set_timestamp_info(packet,timestamp);
mblk_set_timestamp_info(vp8_payload_desc,timestamp);
/* insert 1 byte vp8 payload descriptor */
(*vp8_payload_desc->b_rptr) = 0;
/* X (extended) field, 0 */
(*vp8_payload_desc->b_rptr) &= ~VP8_PAYLOAD_DESC_X_MASK;
/* RSV field, always 0 */
(*vp8_payload_desc->b_rptr) &= ~VP8_PAYLOAD_DESC_RSV_MASK;
/* N : set to 1 if non reference frame */
if ((pkt->data.frame.flags & VPX_FRAME_IS_KEY) == 0)
(*vp8_payload_desc->b_rptr) |= VP8_PAYLOAD_DESC_N_MASK;
/* S : partition start */
if (rptr == frame->b_rptr) {
(*vp8_payload_desc->b_rptr) |= VP8_PAYLOAD_DESC_S_MASK;
}
/* PartID : partition id */
#ifdef FRAGMENT_ON_PARTITIONS
(*vp8_payload_desc->b_rptr) |= (pkt->data.frame.partition_id & VP8_PAYLOAD_DESC_PARTID_MASK);