vp8.c 15.9 KB
Newer Older
1
 /*
Simon Morlat's avatar
Simon Morlat committed
2
 * vp8.c -VP8 encoder/decoder wrapper
3 4 5 6 7 8 9 10 11 12 13 14
 *
 *
 * Copyright (C) 2011  Belledonne Communications, Grenoble, France
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Simon Morlat's avatar
Simon Morlat committed
15
 *  GNU General Public License for more details.
16 17 18 19 20 21
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

22 23 24 25 26 27 28 29 30 31
#include "mediastreamer2/msfilter.h"
#include "mediastreamer2/msticker.h"
#include "mediastreamer2/msvideo.h"

#define VPX_CODEC_DISABLE_COMPAT 1
#include <vpx/vpx_encoder.h>
#include <vpx/vp8cx.h>

#define interface (vpx_codec_vp8_cx())

32 33 34 35 36
#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
37

38
#undef FRAGMENT_ON_PARTITIONS
39

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
/* 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;
}

70 71 72
typedef struct EncState {
	vpx_codec_ctx_t codec;
	vpx_codec_enc_cfg_t cfg;
73
	int bitrate;
74
	int width, height;
75
	long long frame_count;
76 77
	unsigned int mtu;
	float fps;
78 79
	VideoStarter starter;
	bool_t req_vfu;
80
	bool_t ready;
81 82 83
#ifdef FRAGMENT_ON_PARTITIONS
	uint8_t token_partition_count;
#endif
84 85
} EncState;

86
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);
87 88 89

static void enc_init(MSFilter *f) {
	vpx_codec_err_t res;
90
	EncState *s=(EncState *)ms_new0(EncState,1);
91 92 93 94 95 96 97

	ms_message("Using %s\n",vpx_codec_iface_name(interface));

	/* 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));
98
	}
99 100 101

	s->width = MS_VIDEO_SIZE_CIF_W;
	s->height = MS_VIDEO_SIZE_CIF_H;
102
	s->bitrate=256000;
103
	s->frame_count = 0;
104 105
	s->cfg.g_w = s->width;
	s->cfg.g_h = s->height;
106 107
	/* encoder automatically places keyframes */
	s->cfg.kf_mode = VPX_KF_AUTO;
108
	s->cfg.kf_max_dist = 300;
109
	s->cfg.rc_target_bitrate = ((float)s->bitrate)*0.92/1024.0; //0.9=take into account IP/UDP/RTP overhead, in average.
110
	s->cfg.g_pass = VPX_RC_ONE_PASS; /* -p 1 */
111 112 113
	s->fps=15;
	s->cfg.g_timebase.num = 1;
	s->cfg.g_timebase.den = s->fps;
114
	s->cfg.rc_end_usage = VPX_CBR; /* --end-usage=cbr */
Simon Morlat's avatar
Simon Morlat committed
115
	s->cfg.g_threads = 1; /* single thread*/
116
	s->cfg.rc_undershoot_pct = 95; /* --undershoot-pct=95 */
117
	s->cfg.g_error_resilient = 1;
118
	s->cfg.g_lag_in_frames = 0;
119 120
	s->mtu=ms_get_payload_max_size()-1;/*-1 for the vp8 payload header*/

121 122 123 124 125
	f->data = s;
}

static void enc_uninit(MSFilter *f) {
	EncState *s=(EncState*)f->data;
126
	
127 128 129 130
	ms_free(s);
}

static void enc_preprocess(MSFilter *f) {
131
	vpx_codec_err_t res;
132
	EncState *s=(EncState*)f->data;
133 134 135

	s->cfg.g_w = s->width;
	s->cfg.g_h = s->height;
136
	s->cfg.g_timebase.den=s->fps;
137
	/* Initialize codec */
138 139 140 141
	#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
142
	res =  vpx_codec_enc_init(&s->codec, interface, &s->cfg, 0);
143
	#endif
144 145 146
	if (res) {
		ms_error("vpx_codec_enc_init failed: %s (%s)n", vpx_codec_err_to_string(res), vpx_codec_error_detail(&s->codec));
	}
Simon Morlat's avatar
Simon Morlat committed
147
    /*cpu/quality tradeoff: positive values decrease CPU usage at the expense of quality*/
148
	vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, 10); 
149 150
	vpx_codec_control(&s->codec, VP8E_SET_STATIC_THRESHOLD, 0);
	vpx_codec_control(&s->codec, VP8E_SET_ENABLEAUTOALTREF, 1);
151 152 153 154
	#ifdef FRAGMENT_ON_PARTITIONS
	vpx_codec_control(&s->codec, VP8E_SET_TOKEN_PARTITIONS, 0x3);
	s->token_partition_count = 8;
	#endif
155
	/* vpx_codec_control(&s->codec, VP8E_SET_CPUUSED, 0);*/ /* -16 (quality) .. 16 (speed) */
156 157

	video_starter_init(&s->starter);
158
	s->ready=TRUE;
159 160 161 162 163 164 165 166 167
}

static void enc_process(MSFilter *f) {
	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;
168
	YuvBuf yuv;
169

170
	ms_filter_lock(f);
171
	while((im=ms_queue_get(f->inputs[0]))!=NULL){
172
		vpx_image_t img;
173

174 175 176
		om = NULL;
		flags = 0;

177 178 179
		ms_yuv_buf_init_from_mblk(&yuv, im);
		vpx_img_wrap(&img, VPX_IMG_FMT_I420, s->width, s->height, 1, yuv.planes[0]);
		
180 181 182 183 184 185 186 187 188
		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->req_vfu){
			flags = VPX_EFLAG_FORCE_KF;
			s->req_vfu=FALSE;
		}

189
		err = vpx_codec_encode(&s->codec, &img, s->frame_count, 1, flags, VPX_DL_REALTIME);
190

191 192 193 194
		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;
195
			const vpx_codec_cx_pkt_t *pkt;
196

197 198 199 200 201
			s->frame_count++;
			if (s->frame_count==1){
				video_starter_first_frame (&s->starter,f->ticker->time);
			}

202
			while( (pkt = vpx_codec_get_cx_data(&s->codec, &iter)) ) {
203
				if (pkt->kind == VPX_CODEC_CX_FRAME_PKT) {
204
					if (pkt->data.frame.sz > 0) {
205 206 207 208 209 210 211 212
						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
213
					}
214 215 216 217 218
				}
			}
		}
		freemsg(im);
	}
219
	ms_filter_unlock(f);
220 221 222
}

static void enc_postprocess(MSFilter *f) {
223 224 225
	EncState *s=(EncState*)f->data;
	if (s->ready) vpx_codec_destroy(&s->codec);
	s->ready=FALSE;
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263
}

static int enc_set_vsize(MSFilter *f, void*data){
	MSVideoSize *vs=(MSVideoSize*)data;
	EncState *s=(EncState*)f->data;
	s->width=vs->width;
	s->height=vs->height;
	return 0;
}

static int enc_get_vsize(MSFilter *f, void *data){
	EncState *s=(EncState*)f->data;
	MSVideoSize *vs=(MSVideoSize*)data;
	vs->width=s->width;
	vs->height=s->height;
	return 0;
}

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->fps=*fps;
	return 0;
}

static int enc_get_fps(MSFilter *f, void *data){
	EncState *s=(EncState*)f->data;
	float *fps=(float*)data;
	*fps=s->fps;
	return 0;
}

264 265 266 267 268 269
static int enc_get_br(MSFilter *f, void*data){
	EncState *s=(EncState*)f->data;
	*(int*)data=s->bitrate;
	return 0;
}

270 271 272
static int enc_set_br(MSFilter *f, void*data){
	int br=*(int*)data;
	EncState *s=(EncState*)f->data;
273 274 275 276 277 278 279 280 281
	s->bitrate=br;
	s->cfg.rc_target_bitrate = ((float)s->bitrate)*0.92/1024.0; //0.9=take into account IP/UDP/RTP overhead, in average.
	if (s->ready){
		ms_filter_lock(f);
		enc_postprocess(f);
		enc_preprocess(f);
		ms_filter_unlock(f);
		return 0;
	}
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310
	if (br>=1024000){
		s->width = MS_VIDEO_SIZE_VGA_W;
		s->height = MS_VIDEO_SIZE_VGA_H;
		s->fps=25;
	}else if (br>=512000){
		s->width = MS_VIDEO_SIZE_CIF_W;
		s->height = MS_VIDEO_SIZE_CIF_H;
		s->fps=25;
	} else if (br>=256000){
		s->width = MS_VIDEO_SIZE_CIF_W;
		s->height = MS_VIDEO_SIZE_CIF_H;
		s->fps=15;
	}else if (br>=170000){
		s->width=MS_VIDEO_SIZE_QVGA_W;
		s->height=MS_VIDEO_SIZE_QVGA_H;
		s->fps=15;
	}else if (br>=128000){
		s->width=MS_VIDEO_SIZE_QVGA_W;
		s->height=MS_VIDEO_SIZE_QVGA_H;
		s->fps=10;
	}else if (br>=64000){
		s->width=MS_VIDEO_SIZE_QCIF_W;
		s->height=MS_VIDEO_SIZE_QCIF_H;
		s->fps=12;
	}else{
		s->width=MS_VIDEO_SIZE_QCIF_W;
		s->height=MS_VIDEO_SIZE_QCIF_H;
		s->fps=5;
	}
jehan's avatar
jehan committed
311
#if TARGET_OS_IPHONE
312 313
	s->width=MS_VIDEO_SIZE_QVGA_W;
	s->height=MS_VIDEO_SIZE_QVGA_H;
jehan's avatar
jehan committed
314
	s->fps=12;
jehan's avatar
jehan committed
315
#endif
316

317
	ms_message("bitrate requested...: %d (%d x %d)\n", br, s->width, s->height);
318 319 320 321 322 323 324 325 326
	return 0;
}

static int enc_set_mtu(MSFilter *f, void*data){
	EncState *s=(EncState*)f->data;
	s->mtu=*(int*)data;
	return 0;
}

327 328 329 330 331 332
static int enc_req_vfu(MSFilter *f, void *unused){
	EncState *s=(EncState*)f->data;
	s->req_vfu=TRUE;
	return 0;
}

333 334 335 336 337 338 339
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	},
340
	{	MS_FILTER_GET_BITRATE,    enc_get_br	},
341
	{	MS_FILTER_SET_MTU,        enc_set_mtu	},
342
	{	MS_FILTER_REQ_VFU,        enc_req_vfu  },
343 344 345
	{	0			, NULL }
};

346 347 348 349 350 351
#ifdef _MSC_VER
MSFilterDesc ms_vp8_enc_desc={
	MS_VP8_ENC_ID,
	"MSVp8Enc",
	N_("A video VP8 encoder using libvpx library."),
	MS_FILTER_ENCODER,
352
	"VP8",
353 354 355 356 357 358 359 360 361 362
	1, /*MS_YUV420P is assumed on this input */
	1,
	enc_init,
	enc_preprocess,
	enc_process,
	enc_postprocess,
	enc_uninit,
	enc_methods
};
#else
363 364 365 366 367
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,
368
	.enc_fmt="VP8",
369 370 371 372 373 374 375 376 377
	.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
};
378
#endif
379 380 381 382

MS_FILTER_DESC_EXPORT(ms_vp8_enc_desc)


383
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){
384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
	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;
410 411
		/* X (extended) field, 0 */
		(*vp8_payload_desc->b_rptr) &= ~VP8_PAYLOAD_DESC_X_MASK;
412 413 414 415
		/* 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)
416 417
			(*vp8_payload_desc->b_rptr) |= VP8_PAYLOAD_DESC_N_MASK;
		/* S : partition start */
418
		if (rptr == frame->b_rptr) {
419
			(*vp8_payload_desc->b_rptr) |= VP8_PAYLOAD_DESC_S_MASK;
420
		}
421
		/* PartID : partition id */
422
		#ifdef FRAGMENT_ON_PARTITIONS
423
		(*vp8_payload_desc->b_rptr) |= (pkt->data.frame.partition_id & VP8_PAYLOAD_DESC_PARTID_MASK);
424
		#endif
425 426 427 428 429 430 431 432 433 434

		vp8_payload_desc->b_cont = packet;

		ms_queue_put(f->outputs[0], vp8_payload_desc);
		rptr+=len;
	}

	freeb(frame);

	/*set marker bit on last packet*/
435 436 437 438
	if (lastPartition) {
		mblk_set_marker_info(packet,TRUE);
		mblk_set_marker_info(vp8_payload_desc,TRUE);
	}
439 440 441 442 443 444 445 446 447 448 449
}

#undef interface
#include <assert.h>
#include <vpx/vpx_decoder.h>
#include <vpx/vp8dx.h>
#define interface (vpx_codec_vp8_dx())

typedef struct DecState {
	vpx_codec_ctx_t codec;
	mblk_t *curframe;
450
	uint64_t last_error_reported_time;
451 452 453 454
	mblk_t *yuv_msg;
	MSPicture outbuf;
	int yuv_width, yuv_height;
	MSQueue q;
455 456 457 458 459 460 461 462 463 464 465 466 467
} DecState;


static void dec_init(MSFilter *f) {
	DecState *s=(DecState *)ms_new(DecState,1);

	ms_message("Using %s\n",vpx_codec_iface_name(interface));

	/* Initialize codec */
	if(vpx_codec_dec_init(&s->codec, interface, NULL, 0))
		ms_error("Failed to initialize decoder");

	s->curframe = NULL;
468
	s->last_error_reported_time = 0;
469 470 471 472
	s->yuv_width = 0;
	s->yuv_height = 0;
	s->yuv_msg = 0;
	ms_queue_init(&s->q);
473 474 475 476 477 478 479 480 481 482 483 484 485
	f->data = s;
}

static void dec_preprocess(MSFilter* f) {

}

static void dec_uninit(MSFilter *f) {
	DecState *s=(DecState*)f->data;
	vpx_codec_destroy(&s->codec);

	if (s->curframe!=NULL)
		freemsg(s->curframe);
486
	if (s->yuv_msg)
Simon Morlat's avatar
Simon Morlat committed
487
		freemsg(s->yuv_msg);
488 489

	ms_queue_flush(&s->q);
490 491 492 493

	ms_free(s);
}

494
/* remove payload header and aggregates fragmented packets */
495 496
static void dec_unpacketize(MSFilter *f, DecState *s, mblk_t *im, MSQueue *out){
	im->b_rptr++;
497

498
	/* end of frame bit ? */
499 500 501
	if (mblk_get_marker_info(im)) {
		/* should be aggregated with previous packet ? */
		if (s->curframe!=NULL){
502
			/* same timestamp ? */
503
			if (mblk_get_timestamp_info(im) == mblk_get_timestamp_info(s->curframe)) {
504
				concatb(s->curframe,im);
505
				msgpullup(s->curframe,-1);
506 507
				/* transmit complete frame */
				ms_queue_put(out, s->curframe);
508 509
				s->curframe=NULL;
			} else {
510 511
				/* transmit partial frame */
				ms_queue_put(out, s->curframe);
512
				s->curframe = NULL;
513 514
				/* transmit new one (be it complete or not) */
				ms_queue_put(out, im);
515 516
			}
		} else {
517 518
			/* transmit new one (be it complete or not) */
			ms_queue_put(out, im);
519
		}
520
	} else {
521 522 523 524 525
		if (s->curframe!=NULL) {
			/* append if same timestamp */
			if (mblk_get_timestamp_info(im) == mblk_get_timestamp_info(s->curframe)) {
				concatb(s->curframe,im);
			} else {
526 527 528
				/* transmit partial frame */
				ms_queue_put(out, s->curframe);
				s->curframe = im;
529 530 531
			}
		}
		else {
532
			s->curframe = im;
533
		}
534 535 536 537 538 539 540 541
	}
}

static void dec_process(MSFilter *f) {
	mblk_t *im;
	DecState *s=(DecState*)f->data;

	while( (im=ms_queue_get(f->inputs[0]))!=0) {
542 543 544 545 546 547
		mblk_t *m;

		dec_unpacketize(f, s, im, &s->q);

		while((m=ms_queue_get(&s->q))!=NULL){
			vpx_codec_err_t err;
548 549 550 551 552 553
			vpx_codec_iter_t  iter = NULL;
			vpx_image_t      *img;

			err = vpx_codec_decode(&s->codec, m->b_rptr, m->b_wptr - m->b_rptr, NULL, 0);
			if (err) {
				ms_warning("vpx_codec_decode failed : %d %s (%s)\n", err, vpx_codec_err_to_string(err), vpx_codec_error_detail(&s->codec));
554 555 556 557 558

				if ((f->ticker->time - s->last_error_reported_time)>5000 || s->last_error_reported_time==0) {
					s->last_error_reported_time=f->ticker->time;
					ms_filter_notify_no_arg(f,MS_VIDEO_DECODER_DECODING_ERRORS);
				}
559 560
			}

561

562
			/* browse decoded frames */
563
			while((img = vpx_codec_get_frame(&s->codec, &iter))) {
564
				int i,j;
565 566 567

				if (s->yuv_width != img->d_w || s->yuv_height != img->d_h) {
					if (s->yuv_msg)
Simon Morlat's avatar
Simon Morlat committed
568
						freemsg(s->yuv_msg);
569 570 571 572 573
					s->yuv_msg = ms_yuv_buf_alloc(&s->outbuf, img->d_w, img->d_h);
					s->yuv_width = img->d_w;
					s->yuv_height = img->d_h;
				}

574
				/* scale/copy frame to destination mblk_t */
575
				for(i=0; i<3; i++) {
576 577
					uint8_t* dest = s->outbuf.planes[i];
					uint8_t* src = img->planes[i];
578
					int h = img->d_h >> ((i>0)?1:0);
579

580
					for(j=0; j<h; j++) {
581
						memcpy(dest, src, s->outbuf.strides[i]);
582

583
						dest += s->outbuf.strides[i];
584 585 586
						src += img->stride[i];
					}
				}
587
				ms_queue_put(f->outputs[0], dupmsg(s->yuv_msg));
588 589 590 591 592 593
			}
			freemsg(m);
		}
	}
}

594 595 596 597 598 599
#ifdef _MSC_VER
MSFilterDesc ms_vp8_dec_desc={
	MS_VP8_DEC_ID,
	"MSVp8Dec",
	"A VP8 decoder using libvpx library",
	MS_FILTER_DECODER,
600
	"VP8",
601 602 603 604 605 606 607 608 609 610
	1,
	1,
	dec_init,
	dec_preprocess,
	dec_process,
	NULL,
	dec_uninit,
	NULL
};
#else
611 612 613 614 615
MSFilterDesc ms_vp8_dec_desc={
	.id=MS_VP8_DEC_ID,
	.name="MSVp8Dec",
	.text="A VP8 decoder using libvpx library",
	.category=MS_FILTER_DECODER,
616
	.enc_fmt="VP8",
617 618 619 620 621 622 623 624 625
	.ninputs=1,
	.noutputs=1,
	.init=dec_init,
	.preprocess=dec_preprocess,
	.process=dec_process,
	.postprocess=NULL,
	.uninit=dec_uninit,
	.methods=NULL
};
626
#endif
627
MS_FILTER_DESC_EXPORT(ms_vp8_dec_desc)