| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
#include "asterisk.h" |
| 27 |
#include "console_video.h" |
| 28 |
#include "asterisk/frame.h" |
| 29 |
#include "asterisk/utils.h" |
| 30 |
|
| 31 |
struct video_out_desc; |
| 32 |
struct video_dec_desc; |
| 33 |
struct fbuf_t; |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
typedef int (*encoder_init_f)(AVCodecContext *v); |
| 40 |
|
| 41 |
|
| 42 |
typedef int (*encoder_encode_f)(struct video_out_desc *v); |
| 43 |
|
| 44 |
|
| 45 |
typedef struct ast_frame *(*encoder_encap_f)(struct fbuf_t *, int mtu, |
| 46 |
struct ast_frame **tail); |
| 47 |
|
| 48 |
|
| 49 |
typedef int (*decoder_init_f)(AVCodecContext *enc_ctx); |
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
typedef int (*decoder_decap_f)(struct fbuf_t *b, uint8_t *data, int len); |
| 55 |
|
| 56 |
|
| 57 |
typedef int (*decoder_decode_f)(struct video_dec_desc *v, struct fbuf_t *b); |
| 58 |
|
| 59 |
struct video_codec_desc { |
| 60 |
const char *name; |
| 61 |
int format; |
| 62 |
encoder_init_f enc_init; |
| 63 |
encoder_encap_f enc_encap; |
| 64 |
encoder_encode_f enc_run; |
| 65 |
decoder_init_f dec_init; |
| 66 |
decoder_decap_f dec_decap; |
| 67 |
decoder_decode_f dec_run; |
| 68 |
}; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
struct video_dec_desc { |
| 85 |
struct video_codec_desc *d_callbacks; |
| 86 |
AVCodecContext *dec_ctx; |
| 87 |
AVCodec *codec; |
| 88 |
AVFrame *d_frame; |
| 89 |
AVCodecParserContext *parser; |
| 90 |
uint16_t next_seq; |
| 91 |
int discard; |
| 92 |
#define N_DEC_IN 3 |
| 93 |
struct fbuf_t *dec_in_cur; |
| 94 |
struct fbuf_t *dec_in_dpy; |
| 95 |
struct fbuf_t dec_in[N_DEC_IN]; |
| 96 |
struct fbuf_t dec_out; |
| 97 |
}; |
| 98 |
|
| 99 |
#ifdef debugging_only |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
struct bitbuf { |
| 105 |
const uint8_t *base; |
| 106 |
int bitsize; |
| 107 |
int ofs; |
| 108 |
}; |
| 109 |
|
| 110 |
static struct bitbuf bitbuf_init(const uint8_t *base, int bitsize, int start_ofs) |
| 111 |
{ |
| 112 |
struct bitbuf a; |
| 113 |
a.base = base; |
| 114 |
a.bitsize = bitsize; |
| 115 |
a.ofs = start_ofs; |
| 116 |
return a; |
| 117 |
} |
| 118 |
|
| 119 |
static int bitbuf_left(struct bitbuf *b) |
| 120 |
{ |
| 121 |
return b->bitsize - b->ofs; |
| 122 |
} |
| 123 |
|
| 124 |
static uint32_t getbits(struct bitbuf *b, int n) |
| 125 |
{ |
| 126 |
int i, ofs; |
| 127 |
const uint8_t *d; |
| 128 |
uint8_t mask; |
| 129 |
uint32_t retval = 0; |
| 130 |
if (n> 31) { |
| 131 |
ast_log(LOG_WARNING, "too many bits %d, max 32\n", n); |
| 132 |
return 0; |
| 133 |
} |
| 134 |
if (n + b->ofs > b->bitsize) { |
| 135 |
ast_log(LOG_WARNING, "bitbuf overflow %d of %d\n", n + b->ofs, b->bitsize); |
| 136 |
n = b->bitsize - b->ofs; |
| 137 |
} |
| 138 |
ofs = 7 - b->ofs % 8; |
| 139 |
mask = 1 << ofs; |
| 140 |
d = b->base + b->ofs / 8; |
| 141 |
for (i=0 ; i < n; i++) { |
| 142 |
retval += retval + (*d & mask ? 1 : 0); |
| 143 |
b->ofs++; |
| 144 |
mask >>= 1; |
| 145 |
if (mask == 0) { |
| 146 |
d++; |
| 147 |
mask = 0x80; |
| 148 |
} |
| 149 |
} |
| 150 |
return retval; |
| 151 |
} |
| 152 |
|
| 153 |
static void check_h261(struct fbuf_t *b) |
| 154 |
{ |
| 155 |
struct bitbuf a = bitbuf_init(b->data, b->used * 8, 0); |
| 156 |
uint32_t x, y; |
| 157 |
|
| 158 |
x = getbits(&a, 20); |
| 159 |
if (x != 0x10) { |
| 160 |
ast_log(LOG_WARNING, "bad PSC 0x%x\n", x); |
| 161 |
return; |
| 162 |
} |
| 163 |
x = getbits(&a, 5); |
| 164 |
y = getbits(&a, 6); |
| 165 |
if (0) |
| 166 |
ast_log(LOG_WARNING, "size %d TR %d PTY spl %d doc %d freeze %d %sCIF hi %d\n", |
| 167 |
b->used, |
| 168 |
x, |
| 169 |
(y & 0x20) ? 1 : 0, |
| 170 |
(y & 0x10) ? 1 : 0, |
| 171 |
(y & 0x8) ? 1 : 0, |
| 172 |
(y & 0x4) ? "" : "Q", |
| 173 |
(y & 0x2) ? 1:0); |
| 174 |
while ( (x = getbits(&a, 1)) == 1) |
| 175 |
ast_log(LOG_WARNING, "PSPARE 0x%x\n", getbits(&a, 8)); |
| 176 |
|
| 177 |
while ( (x = bitbuf_left(&a)) > 0) { |
| 178 |
|
| 179 |
x = getbits(&a, 16); |
| 180 |
if (x != 0x1) { |
| 181 |
ast_log(LOG_WARNING, "bad GBSC 0x%x\n", x); |
| 182 |
break; |
| 183 |
} |
| 184 |
x = getbits(&a, 4); |
| 185 |
y = getbits(&a, 5); |
| 186 |
if (x == 0) { |
| 187 |
ast_log(LOG_WARNING, " bad GN %d\n", x); |
| 188 |
break; |
| 189 |
} |
| 190 |
while ( (x = getbits(&a, 1)) == 1) |
| 191 |
ast_log(LOG_WARNING, "GSPARE 0x%x\n", getbits(&a, 8)); |
| 192 |
while ( (x = bitbuf_left(&a)) > 0) { |
| 193 |
break; |
| 194 |
} |
| 195 |
} |
| 196 |
} |
| 197 |
|
| 198 |
void dump_buf(struct fbuf_t *b); |
| 199 |
void dump_buf(struct fbuf_t *b) |
| 200 |
{ |
| 201 |
int i, x, last2lines; |
| 202 |
char buf[80]; |
| 203 |
|
| 204 |
last2lines = (b->used - 16) & ~0xf; |
| 205 |
ast_log(LOG_WARNING, "buf size %d of %d\n", b->used, b->size); |
| 206 |
for (i = 0; i < b->used; i++) { |
| 207 |
x = i & 0xf; |
| 208 |
if ( x == 0) { |
| 209 |
if (i != 0) |
| 210 |
ast_log(LOG_WARNING, "%s\n", buf); |
| 211 |
memset(buf, '\0', sizeof(buf)); |
| 212 |
sprintf(buf, "%04x: ", (unsigned)i); |
| 213 |
} |
| 214 |
sprintf(buf + 6 + x*3, "%02hhx ", b->data[i]); |
| 215 |
if (i > 31 && i < last2lines) |
| 216 |
i = last2lines - 1; |
| 217 |
} |
| 218 |
if (buf[0]) |
| 219 |
ast_log(LOG_WARNING, "%s\n", buf); |
| 220 |
} |
| 221 |
#endif |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
static struct ast_frame *create_video_frame(uint8_t *start, uint8_t *end, |
| 229 |
int format, int head, struct ast_frame *prev) |
| 230 |
{ |
| 231 |
int len = end-start; |
| 232 |
uint8_t *data; |
| 233 |
struct ast_frame *f; |
| 234 |
|
| 235 |
data = ast_calloc(1, len+head); |
| 236 |
f = ast_calloc(1, sizeof(*f)); |
| 237 |
if (f == NULL || data == NULL) { |
| 238 |
ast_log(LOG_WARNING, "--- frame error f %p data %p len %d format %d\n", |
| 239 |
f, data, len, format); |
| 240 |
if (f) |
| 241 |
ast_free(f); |
| 242 |
if (data) |
| 243 |
ast_free(data); |
| 244 |
return NULL; |
| 245 |
} |
| 246 |
memcpy(data+head, start, len); |
| 247 |
f->data.ptr = data; |
| 248 |
f->mallocd = AST_MALLOCD_DATA | AST_MALLOCD_HDR; |
| 249 |
|
| 250 |
|
| 251 |
f->datalen = len+head; |
| 252 |
f->frametype = AST_FRAME_VIDEO; |
| 253 |
f->subclass = format; |
| 254 |
f->samples = 0; |
| 255 |
f->offset = 0; |
| 256 |
f->src = "Console"; |
| 257 |
f->delivery.tv_sec = 0; |
| 258 |
f->delivery.tv_usec = 0; |
| 259 |
f->seqno = 0; |
| 260 |
AST_LIST_NEXT(f, frame_list) = NULL; |
| 261 |
|
| 262 |
if (prev) |
| 263 |
AST_LIST_NEXT(prev, frame_list) = f; |
| 264 |
|
| 265 |
return f; |
| 266 |
} |
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
static int fbuf_append(struct fbuf_t *b, uint8_t *src, int len, |
| 274 |
int sbit, int ebit) |
| 275 |
{ |
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
int need = len + FF_INPUT_BUFFER_PADDING_SIZE; |
| 281 |
int i; |
| 282 |
uint8_t *dst, mask; |
| 283 |
|
| 284 |
if (b->data == NULL) { |
| 285 |
b->size = need; |
| 286 |
b->used = 0; |
| 287 |
b->ebit = 0; |
| 288 |
b->data = ast_calloc(1, b->size); |
| 289 |
} else if (b->used + need > b->size) { |
| 290 |
b->size = b->used + need; |
| 291 |
b->data = ast_realloc(b->data, b->size); |
| 292 |
} |
| 293 |
if (b->data == NULL) { |
| 294 |
ast_log(LOG_WARNING, "alloc failure for %d, discard\n", |
| 295 |
b->size); |
| 296 |
return 1; |
| 297 |
} |
| 298 |
if (b->used == 0 && b->ebit != 0) { |
| 299 |
ast_log(LOG_WARNING, "ebit not reset at start\n"); |
| 300 |
b->ebit = 0; |
| 301 |
} |
| 302 |
dst = b->data + b->used; |
| 303 |
i = b->ebit + sbit; |
| 304 |
if (i == 0) { |
| 305 |
|
| 306 |
} else if (i == 8) { |
| 307 |
mask = (1 << b->ebit) - 1; |
| 308 |
|
| 309 |
dst[-1] &= ~mask; |
| 310 |
dst[-1] |= (*src & mask); |
| 311 |
src += 1; |
| 312 |
len --; |
| 313 |
} else { |
| 314 |
ast_log(LOG_WARNING, "must handle shift %d %d at %d\n", |
| 315 |
b->ebit, sbit, b->used); |
| 316 |
return 1; |
| 317 |
} |
| 318 |
memcpy(dst, src, len); |
| 319 |
b->used += len; |
| 320 |
b->ebit = ebit; |
| 321 |
b->data[b->used] = 0; |
| 322 |
return 0; |
| 323 |
} |
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
static int h263p_enc_init(AVCodecContext *enc_ctx) |
| 336 |
{ |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
enc_ctx->flags |=CODEC_FLAG_H263P_UMV; |
| 347 |
enc_ctx->flags |=CODEC_FLAG_AC_PRED; |
| 348 |
enc_ctx->flags |=CODEC_FLAG_H263P_SLICE_STRUCT; |
| 349 |
enc_ctx->flags |= CODEC_FLAG_H263P_AIC; |
| 350 |
|
| 351 |
return 0; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
static struct ast_frame *h263p_encap(struct fbuf_t *b, int mtu, |
| 361 |
struct ast_frame **tail) |
| 362 |
{ |
| 363 |
struct ast_frame *cur = NULL, *first = NULL; |
| 364 |
uint8_t *d = b->data; |
| 365 |
int len = b->used; |
| 366 |
int l = len; |
| 367 |
|
| 368 |
for (;len > 0; len -= l, d += l) { |
| 369 |
uint8_t *data; |
| 370 |
struct ast_frame *f; |
| 371 |
int i, h; |
| 372 |
|
| 373 |
if (len >= 3 && d[0] == 0 && d[1] == 0 && d[2] >= 0x80) { |
| 374 |
|
| 375 |
for (i = 3; i < len - 3; i++) { |
| 376 |
if (d[i] == 0 && d[i+1] == 0 && d[i+2] >= 0x80) { |
| 377 |
l = i; |
| 378 |
break; |
| 379 |
} |
| 380 |
} |
| 381 |
} |
| 382 |
if (l > mtu || l > len) { |
| 383 |
l = MIN(len, mtu); |
| 384 |
} |
| 385 |
if (l < 1 || l > mtu) { |
| 386 |
ast_log(LOG_WARNING, "--- frame error l %d\n", l); |
| 387 |
break; |
| 388 |
} |
| 389 |
|
| 390 |
if (d[0] == 0 && d[1] == 0) { |
| 391 |
h = 0; |
| 392 |
} else { |
| 393 |
h = 2; |
| 394 |
} |
| 395 |
|
| 396 |
f = create_video_frame(d, d+l, AST_FORMAT_H263_PLUS, h, cur); |
| 397 |
if (!f) |
| 398 |
break; |
| 399 |
|
| 400 |
data = f->data.ptr; |
| 401 |
if (h == 0) { |
| 402 |
data[0] |= 0x04; |
| 403 |
} else { |
| 404 |
data[0] = data[1] = 0; |
| 405 |
} |
| 406 |
|
| 407 |
if (!cur) |
| 408 |
first = f; |
| 409 |
cur = f; |
| 410 |
} |
| 411 |
|
| 412 |
if (cur) |
| 413 |
cur->subclass |= 1; |
| 414 |
|
| 415 |
*tail = cur; |
| 416 |
return first; |
| 417 |
} |
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
static int h263p_decap(struct fbuf_t *b, uint8_t *data, int len) |
| 434 |
{ |
| 435 |
int PLEN; |
| 436 |
|
| 437 |
if (len < 2) { |
| 438 |
ast_log(LOG_WARNING, "invalid framesize %d\n", len); |
| 439 |
return 1; |
| 440 |
} |
| 441 |
PLEN = ( (data[0] & 1) << 5 ) | ( (data[1] & 0xf8) >> 3); |
| 442 |
|
| 443 |
if (PLEN > 0) { |
| 444 |
data += PLEN; |
| 445 |
len -= PLEN; |
| 446 |
} |
| 447 |
if (data[0] & 4) |
| 448 |
data[0] = data[1] = 0; |
| 449 |
else { |
| 450 |
data += 2; |
| 451 |
len -= 2; |
| 452 |
} |
| 453 |
return fbuf_append(b, data, len, 0, 0); |
| 454 |
} |
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
static int ffmpeg_encode(struct video_out_desc *v) |
| 462 |
{ |
| 463 |
struct fbuf_t *b = &v->enc_out; |
| 464 |
int i; |
| 465 |
|
| 466 |
b->used = avcodec_encode_video(v->enc_ctx, b->data, b->size, v->enc_in_frame); |
| 467 |
i = avcodec_encode_video(v->enc_ctx, b->data + b->used, b->size - b->used, NULL); |
| 468 |
if (i > 0) { |
| 469 |
ast_log(LOG_WARNING, "have %d more bytes\n", i); |
| 470 |
b->used += i; |
| 471 |
} |
| 472 |
return 0; |
| 473 |
} |
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
static int ffmpeg_decode(struct video_dec_desc *v, struct fbuf_t *b) |
| 483 |
{ |
| 484 |
uint8_t *src = b->data; |
| 485 |
int srclen = b->used; |
| 486 |
int full_frame = 0; |
| 487 |
|
| 488 |
if (srclen == 0) |
| 489 |
return 0; |
| 490 |
while (srclen) { |
| 491 |
uint8_t *data; |
| 492 |
int datalen, ret; |
| 493 |
int len = av_parser_parse(v->parser, v->dec_ctx, &data, &datalen, src, srclen, 0, 0); |
| 494 |
|
| 495 |
src += len; |
| 496 |
srclen -= len; |
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
if (data == NULL || datalen == 0) |
| 501 |
continue; |
| 502 |
ret = avcodec_decode_video(v->dec_ctx, v->d_frame, &full_frame, data, datalen); |
| 503 |
if (full_frame == 1) |
| 504 |
break; |
| 505 |
if (ret < 0) { |
| 506 |
ast_log(LOG_NOTICE, "Error decoding\n"); |
| 507 |
break; |
| 508 |
} |
| 509 |
} |
| 510 |
if (srclen != 0) |
| 511 |
memmove(b->data, src, srclen); |
| 512 |
b->used = srclen; |
| 513 |
b->ebit = 0; |
| 514 |
return full_frame; |
| 515 |
} |
| 516 |
|
| 517 |
static struct video_codec_desc h263p_codec = { |
| 518 |
.name = "h263p", |
| 519 |
.format = AST_FORMAT_H263_PLUS, |
| 520 |
.enc_init = h263p_enc_init, |
| 521 |
.enc_encap = h263p_encap, |
| 522 |
.enc_run = ffmpeg_encode, |
| 523 |
.dec_init = NULL, |
| 524 |
.dec_decap = h263p_decap, |
| 525 |
.dec_run = ffmpeg_decode |
| 526 |
}; |
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
static int h263_enc_init(AVCodecContext *enc_ctx) |
| 531 |
{ |
| 532 |
|
| 533 |
enc_ctx->flags |= CODEC_FLAG_H263P_UMV; |
| 534 |
enc_ctx->flags |= CODEC_FLAG_H263P_AIC; |
| 535 |
enc_ctx->flags |= CODEC_FLAG_H263P_SLICE_STRUCT; |
| 536 |
enc_ctx->flags |= CODEC_FLAG_AC_PRED; |
| 537 |
|
| 538 |
return 0; |
| 539 |
} |
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
static struct ast_frame *h263_encap(struct fbuf_t *b, int mtu, |
| 576 |
struct ast_frame **tail) |
| 577 |
{ |
| 578 |
uint8_t *d = b->data; |
| 579 |
int start = 0, i, len = b->used; |
| 580 |
struct ast_frame *f, *cur = NULL, *first = NULL; |
| 581 |
const int pheader_len = 4; |
| 582 |
uint8_t h263_hdr[12]; |
| 583 |
uint8_t *h = h263_hdr; |
| 584 |
|
| 585 |
#define H263_MIN_LEN 6 |
| 586 |
if (len < H263_MIN_LEN) |
| 587 |
return NULL; |
| 588 |
|
| 589 |
memset(h263_hdr, '\0', sizeof(h263_hdr)); |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
h[1] = ( (d[4] & 0x1f) << 3 ) | |
| 603 |
( (d[5] & 0xc0) >> 5 ); |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
for (i = H263_MIN_LEN, start = 0; start < len; start = i, i += 3) { |
| 610 |
|
| 611 |
for (; i < len ; i++) { |
| 612 |
uint8_t x, rpos, lpos; |
| 613 |
int rpos_i; |
| 614 |
if (d[i] != 0) |
| 615 |
continue; |
| 616 |
if (i > len - 1) |
| 617 |
break; |
| 618 |
x = d[i+1]; |
| 619 |
if (x == 0) |
| 620 |
continue; |
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
for (rpos = 0x80, rpos_i = 8; rpos; rpos >>= 1, rpos_i--) |
| 627 |
if (x & rpos) |
| 628 |
break; |
| 629 |
x = d[i-1]; |
| 630 |
for (lpos = rpos; lpos ; lpos >>= 1) |
| 631 |
if (x & lpos) |
| 632 |
break; |
| 633 |
if (lpos) |
| 634 |
continue; |
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
if (rpos == 0x80) { |
| 639 |
i = i - 1; |
| 640 |
} else { |
| 641 |
ast_log(LOG_WARNING, "unaligned GBSC 0x%x %d\n", |
| 642 |
rpos, rpos_i); |
| 643 |
} |
| 644 |
break; |
| 645 |
} |
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
f = create_video_frame(d + start, d+i, AST_FORMAT_H263, |
| 650 |
pheader_len, cur); |
| 651 |
|
| 652 |
if (!f) |
| 653 |
break; |
| 654 |
memmove(f->data.ptr, h, 4); |
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
if (!cur) |
| 659 |
first = f; |
| 660 |
cur = f; |
| 661 |
} |
| 662 |
|
| 663 |
if (cur) |
| 664 |
cur->subclass |= 1; |
| 665 |
|
| 666 |
*tail = cur; |
| 667 |
return first; |
| 668 |
} |
| 669 |
|
| 670 |
|
| 671 |
static int h263_decap(struct fbuf_t *b, uint8_t *data, int len) |
| 672 |
{ |
| 673 |
if (len < 4) { |
| 674 |
ast_log(LOG_WARNING, "invalid framesize %d\n", len); |
| 675 |
return 1; |
| 676 |
} |
| 677 |
|
| 678 |
if ( (data[0] & 0x80) == 0) { |
| 679 |
len -= 4; |
| 680 |
data += 4; |
| 681 |
} else { |
| 682 |
ast_log(LOG_WARNING, "unsupported mode 0x%x\n", |
| 683 |
data[0]); |
| 684 |
return 1; |
| 685 |
} |
| 686 |
return fbuf_append(b, data, len, 0, 0); |
| 687 |
} |
| 688 |
|
| 689 |
static struct video_codec_desc h263_codec = { |
| 690 |
.name = "h263", |
| 691 |
.format = AST_FORMAT_H263, |
| 692 |
.enc_init = h263_enc_init, |
| 693 |
.enc_encap = h263_encap, |
| 694 |
.enc_run = ffmpeg_encode, |
| 695 |
.dec_init = NULL, |
| 696 |
.dec_decap = h263_decap, |
| 697 |
.dec_run = ffmpeg_decode |
| 698 |
|
| 699 |
}; |
| 700 |
|
| 701 |
|
| 702 |
static int h261_enc_init(AVCodecContext *enc_ctx) |
| 703 |
{ |
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
enc_ctx->rtp_payload_size = 0; |
| 709 |
|
| 710 |
return 0; |
| 711 |
} |
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
static struct ast_frame *h261_encap(struct fbuf_t *b, int mtu, |
| 730 |
struct ast_frame **tail) |
| 731 |
{ |
| 732 |
uint8_t *d = b->data; |
| 733 |
int start = 0, i, len = b->used; |
| 734 |
struct ast_frame *f, *cur = NULL, *first = NULL; |
| 735 |
const int pheader_len = 4; |
| 736 |
uint8_t h261_hdr[4]; |
| 737 |
uint8_t *h = h261_hdr; |
| 738 |
int sbit = 0, ebit = 0; |
| 739 |
|
| 740 |
#define H261_MIN_LEN 10 |
| 741 |
if (len < H261_MIN_LEN) |
| 742 |
return NULL; |
| 743 |
|
| 744 |
memset(h261_hdr, '\0', sizeof(h261_hdr)); |
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
for (i = H261_MIN_LEN, start = 0; start < len - 1; start = i, i += 4) { |
| 752 |
#if 0 |
| 753 |
i = len; |
| 754 |
#else |
| 755 |
int found = 0, found_ebit = 0; |
| 756 |
for (; i < len ; i++) { |
| 757 |
uint8_t x, rpos, lpos; |
| 758 |
if (d[i] != 0) |
| 759 |
continue; |
| 760 |
x = d[i+1]; |
| 761 |
if (x == 0) |
| 762 |
continue; |
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
for (rpos = 0x80, ebit = 7; rpos; ebit--, rpos >>= 1) |
| 769 |
if (x & rpos) |
| 770 |
break; |
| 771 |
x = d[i-1]; |
| 772 |
for (lpos = (rpos >> 1); lpos ; lpos >>= 1) |
| 773 |
if (x & lpos) |
| 774 |
break; |
| 775 |
if (lpos) |
| 776 |
continue; |
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
if (i - start > mtu) |
| 781 |
break; |
| 782 |
found_ebit = ebit; |
| 783 |
found = i; |
| 784 |
i += 4; |
| 785 |
} |
| 786 |
if (i >= len) { |
| 787 |
i = len; |
| 788 |
ebit = 0; |
| 789 |
} |
| 790 |
if (i - start > mtu && found) { |
| 791 |
|
| 792 |
i = found; |
| 793 |
ebit = found_ebit; |
| 794 |
} |
| 795 |
#endif |
| 796 |
if (i - start < 4) |
| 797 |
continue; |
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
f = create_video_frame(d + start, d+i, AST_FORMAT_H261, |
| 802 |
pheader_len, cur); |
| 803 |
|
| 804 |
if (!f) |
| 805 |
break; |
| 806 |
|
| 807 |
h[0] = ( (sbit & 7) << 5 ) | ( (ebit & 7) << 2 ) | 1; |
| 808 |
memmove(f->data.ptr, h, 4); |
| 809 |
if (ebit) |
| 810 |
i--; |
| 811 |
sbit = (8 - ebit) & 7; |
| 812 |
ebit = 0; |
| 813 |
if (!cur) |
| 814 |
first = f; |
| 815 |
cur = f; |
| 816 |
} |
| 817 |
if (cur) |
| 818 |
cur->subclass |= 1; |
| 819 |
|
| 820 |
*tail = cur; |
| 821 |
return first; |
| 822 |
} |
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
static int h261_decap(struct fbuf_t *b, uint8_t *data, int len) |
| 828 |
{ |
| 829 |
int ebit, sbit; |
| 830 |
|
| 831 |
if (len < 8) { |
| 832 |
ast_log(LOG_WARNING, "invalid framesize %d\n", len); |
| 833 |
return 1; |
| 834 |
} |
| 835 |
sbit = (data[0] >> 5) & 7; |
| 836 |
ebit = (data[0] >> 2) & 7; |
| 837 |
len -= 4; |
| 838 |
data += 4; |
| 839 |
return fbuf_append(b, data, len, sbit, ebit); |
| 840 |
} |
| 841 |
|
| 842 |
static struct video_codec_desc h261_codec = { |
| 843 |
.name = "h261", |
| 844 |
.format = AST_FORMAT_H261, |
| 845 |
.enc_init = h261_enc_init, |
| 846 |
.enc_encap = h261_encap, |
| 847 |
.enc_run = ffmpeg_encode, |
| 848 |
.dec_init = NULL, |
| 849 |
.dec_decap = h261_decap, |
| 850 |
.dec_run = ffmpeg_decode |
| 851 |
}; |
| 852 |
|
| 853 |
|
| 854 |
static int mpeg4_enc_init(AVCodecContext *enc_ctx) |
| 855 |
{ |
| 856 |
#if 0 |
| 857 |
|
| 858 |
enc_ctx->flags |= CODEC_FLAG_AC_PRED; |
| 859 |
enc_ctx->flags |= CODEC_FLAG_H263P_UMV; |
| 860 |
enc_ctx->flags |= CODEC_FLAG_QPEL; |
| 861 |
enc_ctx->flags |= CODEC_FLAG_4MV; |
| 862 |
enc_ctx->flags |= CODEC_FLAG_GMC; |
| 863 |
enc_ctx->flags |= CODEC_FLAG_LOOP_FILTER; |
| 864 |
enc_ctx->flags |= CODEC_FLAG_H263P_SLICE_STRUCT; |
| 865 |
#endif |
| 866 |
enc_ctx->rtp_payload_size = 0; |
| 867 |
return 0; |
| 868 |
} |
| 869 |
|
| 870 |
|
| 871 |
static struct ast_frame *mpeg4_encap(struct fbuf_t *b, int mtu, |
| 872 |
struct ast_frame **tail) |
| 873 |
{ |
| 874 |
struct ast_frame *f, *cur = NULL, *first = NULL; |
| 875 |
uint8_t *d = b->data; |
| 876 |
uint8_t *end = d + b->used; |
| 877 |
int len; |
| 878 |
|
| 879 |
for (;d < end; d += len, cur = f) { |
| 880 |
len = MIN(mtu, end - d); |
| 881 |
f = create_video_frame(d, d + len, AST_FORMAT_MP4_VIDEO, 0, cur); |
| 882 |
if (!f) |
| 883 |
break; |
| 884 |
if (!first) |
| 885 |
first = f; |
| 886 |
} |
| 887 |
if (cur) |
| 888 |
cur->subclass |= 1; |
| 889 |
*tail = cur; |
| 890 |
return first; |
| 891 |
} |
| 892 |
|
| 893 |
static int mpeg4_decap(struct fbuf_t *b, uint8_t *data, int len) |
| 894 |
{ |
| 895 |
return fbuf_append(b, data, len, 0, 0); |
| 896 |
} |
| 897 |
|
| 898 |
static int mpeg4_decode(struct video_dec_desc *v, struct fbuf_t *b) |
| 899 |
{ |
| 900 |
int full_frame = 0, datalen = b->used; |
| 901 |
int ret = avcodec_decode_video(v->dec_ctx, v->d_frame, &full_frame, |
| 902 |
b->data, datalen); |
| 903 |
if (ret < 0) { |
| 904 |
ast_log(LOG_NOTICE, "Error decoding\n"); |
| 905 |
ret = datalen; |
| 906 |
} |
| 907 |
datalen -= ret; |
| 908 |
if (datalen > 0) |
| 909 |
memmove(b->data, b->data + ret, datalen); |
| 910 |
b->used = datalen; |
| 911 |
b->ebit = 0; |
| 912 |
return full_frame; |
| 913 |
} |
| 914 |
|
| 915 |
static struct video_codec_desc mpeg4_codec = { |
| 916 |
.name = "mpeg4", |
| 917 |
.format = AST_FORMAT_MP4_VIDEO, |
| 918 |
.enc_init = mpeg4_enc_init, |
| 919 |
.enc_encap = mpeg4_encap, |
| 920 |
.enc_run = ffmpeg_encode, |
| 921 |
.dec_init = NULL, |
| 922 |
.dec_decap = mpeg4_decap, |
| 923 |
.dec_run = mpeg4_decode |
| 924 |
}; |
| 925 |
|
| 926 |
static int h264_enc_init(AVCodecContext *enc_ctx) |
| 927 |
{ |
| 928 |
enc_ctx->flags |= CODEC_FLAG_TRUNCATED; |
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
enc_ctx->rtp_mode = 0; |
| 933 |
enc_ctx->rtp_payload_size = 0; |
| 934 |
enc_ctx->bit_rate_tolerance = enc_ctx->bit_rate; |
| 935 |
return 0; |
| 936 |
} |
| 937 |
|
| 938 |
static int h264_dec_init(AVCodecContext *dec_ctx) |
| 939 |
{ |
| 940 |
dec_ctx->flags |= CODEC_FLAG_TRUNCATED; |
| 941 |
|
| 942 |
return 0; |
| 943 |
} |
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
static struct ast_frame *h264_encap(struct fbuf_t *b, int mtu, |
| 960 |
struct ast_frame **tail) |
| 961 |
{ |
| 962 |
struct ast_frame *f = NULL, *cur = NULL, *first = NULL; |
| 963 |
uint8_t *d, *start = b->data; |
| 964 |
uint8_t *end = start + b->used; |
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
#define HAVE_NAL(x) (x[-4] == 0 && x[-3] == 0 && x[-2] == 0 && x[-1] == 1) |
| 970 |
for (start += 4; start < end; start++) { |
| 971 |
int ty = start[0] & 0x1f; |
| 972 |
if (HAVE_NAL(start) && ty != 0 && ty != 31) |
| 973 |
break; |
| 974 |
} |
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
|
| 980 |
for (;start < end - 4; start = d) { |
| 981 |
int size; |
| 982 |
uint8_t hdr[2]; |
| 983 |
int ty = 0; |
| 984 |
|
| 985 |
|
| 986 |
for (d = start + 4; d < end; d++) { |
| 987 |
ty = d[0] & 0x1f; |
| 988 |
if (HAVE_NAL(d)) |
| 989 |
break; |
| 990 |
} |
| 991 |
|
| 992 |
if (d >= end) { |
| 993 |
d = end + 4; |
| 994 |
} else if (ty == 0 || ty == 31) { |
| 995 |
ast_log(LOG_WARNING, "skip invalid nal type %d at %d of %d\n", |
| 996 |
ty, d - (uint8_t *)b->data, b->used); |
| 997 |
continue; |
| 998 |
} |
| 999 |
|
| 1000 |
size = d - start - 4; |
| 1001 |
|
| 1002 |
if (size < mtu) { |
| 1003 |
|
| 1004 |
f = create_video_frame(start, d - 4, AST_FORMAT_H264, 0, cur); |
| 1005 |
if (!f) |
| 1006 |
break; |
| 1007 |
if (!first) |
| 1008 |
first = f; |
| 1009 |
|
| 1010 |
cur = f; |
| 1011 |
continue; |
| 1012 |
} |
| 1013 |
|
| 1014 |
|
| 1015 |
hdr[0] = (*start & 0xe0) | 28; |
| 1016 |
hdr[1] = (*start++ & 0x1f) | 0x80 ; |
| 1017 |
size--; |
| 1018 |
while (size) { |
| 1019 |
uint8_t *data; |
| 1020 |
int frag_size = MIN(size, mtu); |
| 1021 |
|
| 1022 |
f = create_video_frame(start, start+frag_size, AST_FORMAT_H264, 2, cur); |
| 1023 |
if (!f) |
| 1024 |
break; |
| 1025 |
size -= frag_size; |
| 1026 |
start += frag_size; |
| 1027 |
|
| 1028 |
data = f->data.ptr; |
| 1029 |
data[0] = hdr[0]; |
| 1030 |
data[1] = hdr[1] | (size == 0 ? 0x40 : 0); |
| 1031 |
hdr[1] &= ~0x80; |
| 1032 |
if (!first) |
| 1033 |
first = f; |
| 1034 |
cur = f; |
| 1035 |
} |
| 1036 |
} |
| 1037 |
|
| 1038 |
if (cur) |
| 1039 |
cur->subclass |= 1; |
| 1040 |
|
| 1041 |
*tail = cur; |
| 1042 |
|
| 1043 |
return first; |
| 1044 |
} |
| 1045 |
|
| 1046 |
static int h264_decap(struct fbuf_t *b, uint8_t *data, int len) |
| 1047 |
{ |
| 1048 |
|
| 1049 |
uint8_t scp[] = { 0x00, 0x00, 0x00, 0x01 }; |
| 1050 |
int retval = 0; |
| 1051 |
int type, ofs = 0; |
| 1052 |
|
| 1053 |
if (len < 2) { |
| 1054 |
ast_log(LOG_WARNING, "--- invalid len %d\n", len); |
| 1055 |
return 1; |
| 1056 |
} |
| 1057 |
|
| 1058 |
if (data[0] & 0x80) { |
| 1059 |
ast_log(LOG_WARNING, "--- forbidden packet; nal: %02hhx\n", |
| 1060 |
data[0]); |
| 1061 |
return 1; |
| 1062 |
} |
| 1063 |
|
| 1064 |
type = data[0] & 0x1f; |
| 1065 |
switch (type) { |
| 1066 |
case 0: |
| 1067 |
case 31: |
| 1068 |
ast_log(LOG_WARNING, "--- invalid type: %d\n", type); |
| 1069 |
return 1; |
| 1070 |
case 24: |
| 1071 |
case 25: |
| 1072 |
case 26: |
| 1073 |
case 27: |
| 1074 |
case 29: |
| 1075 |
ast_log(LOG_WARNING, "--- encapsulation not supported : %d\n", type); |
| 1076 |
return 1; |
| 1077 |
case 28: |
| 1078 |
if (data[1] & 0x80) { |
| 1079 |
data[1] &= 0x1f; |
| 1080 |
data[1] |= (data[0] & 0xe0); |
| 1081 |
retval = fbuf_append(b, scp, sizeof(scp), 0, 0); |
| 1082 |
ofs = 1; |
| 1083 |
} else { |
| 1084 |
ofs = 2; |
| 1085 |
} |
| 1086 |
break; |
| 1087 |
default: |
| 1088 |
retval = fbuf_append(b, scp, sizeof(scp), 0, 0); |
| 1089 |
} |
| 1090 |
if (!retval) |
| 1091 |
retval = fbuf_append(b, data + ofs, len - ofs, 0, 0); |
| 1092 |
if (retval) |
| 1093 |
ast_log(LOG_WARNING, "result %d\n", retval); |
| 1094 |
return retval; |
| 1095 |
} |
| 1096 |
|
| 1097 |
static struct video_codec_desc h264_codec = { |
| 1098 |
.name = "h264", |
| 1099 |
.format = AST_FORMAT_H264, |
| 1100 |
.enc_init = h264_enc_init, |
| 1101 |
.enc_encap = h264_encap, |
| 1102 |
.enc_run = ffmpeg_encode, |
| 1103 |
.dec_init = h264_dec_init, |
| 1104 |
.dec_decap = h264_decap, |
| 1105 |
.dec_run = ffmpeg_decode |
| 1106 |
}; |
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
|
| 1113 |
struct _cm { |
| 1114 |
uint32_t ast_format; |
| 1115 |
enum CodecID codec; |
| 1116 |
enum { CM_RD = 1, CM_WR = 2, CM_RDWR = 3 } rw; |
| 1117 |
|
| 1118 |
}; |
| 1119 |
|
| 1120 |
static const struct _cm video_formats[] = { |
| 1121 |
{ AST_FORMAT_H263_PLUS, CODEC_ID_H263, CM_RD }, |
| 1122 |
{ AST_FORMAT_H263_PLUS, CODEC_ID_H263P, CM_WR }, |
| 1123 |
{ AST_FORMAT_H263, CODEC_ID_H263, CM_RD }, |
| 1124 |
{ AST_FORMAT_H263, CODEC_ID_H263, CM_WR }, |
| 1125 |
{ AST_FORMAT_H261, CODEC_ID_H261, CM_RDWR }, |
| 1126 |
{ AST_FORMAT_H264, CODEC_ID_H264, CM_RDWR }, |
| 1127 |
{ AST_FORMAT_MP4_VIDEO, CODEC_ID_MPEG4, CM_RDWR }, |
| 1128 |
{ 0, 0, 0 }, |
| 1129 |
}; |
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
static enum CodecID map_video_format(uint32_t ast_format, int rw) |
| 1134 |
{ |
| 1135 |
struct _cm *i; |
| 1136 |
|
| 1137 |
for (i = video_formats; i->ast_format != 0; i++) |
| 1138 |
if (ast_format & i->ast_format && rw & i->rw) { |
| 1139 |
return i->codec; |
| 1140 |
} |
| 1141 |
return CODEC_ID_NONE; |
| 1142 |
} |
| 1143 |
|
| 1144 |
|
| 1145 |
static const struct video_codec_desc *supported_codecs[] = { |
| 1146 |
&h263p_codec, |
| 1147 |
&h264_codec, |
| 1148 |
&h263_codec, |
| 1149 |
&h261_codec, |
| 1150 |
&mpeg4_codec, |
| 1151 |
NULL |
| 1152 |
}; |
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
|
| 1157 |
|
| 1158 |
static struct video_codec_desc *map_video_codec(int fmt) |
| 1159 |
{ |
| 1160 |
int i; |
| 1161 |
|
| 1162 |
for (i = 0; supported_codecs[i]; i++) |
| 1163 |
if (fmt == supported_codecs[i]->format) { |
| 1164 |
ast_log(LOG_WARNING, "using %s for format 0x%x\n", |
| 1165 |
supported_codecs[i]->name, fmt); |
| 1166 |
return supported_codecs[i]; |
| 1167 |
} |
| 1168 |
return NULL; |
| 1169 |
} |
| 1170 |
|
| 1171 |
|
| 1172 |
static struct video_dec_desc *dec_uninit(struct video_dec_desc *v) |
| 1173 |
{ |
| 1174 |
int i; |
| 1175 |
|
| 1176 |
if (v == NULL) |
| 1177 |
return NULL; |
| 1178 |
if (v->parser) { |
| 1179 |
av_parser_close(v->parser); |
| 1180 |
v->parser = NULL; |
| 1181 |
} |
| 1182 |
if (v->dec_ctx) { |
| 1183 |
avcodec_close(v->dec_ctx); |
| 1184 |
av_free(v->dec_ctx); |
| 1185 |
v->dec_ctx = NULL; |
| 1186 |
} |
| 1187 |
if (v->d_frame) { |
| 1188 |
av_free(v->d_frame); |
| 1189 |
v->d_frame = NULL; |
| 1190 |
} |
| 1191 |
v->codec = NULL; |
| 1192 |
v->d_callbacks = NULL; |
| 1193 |
v->discard = 1; |
| 1194 |
for (i = 0; i < N_DEC_IN; i++) |
| 1195 |
fbuf_free(&v->dec_in[i]); |
| 1196 |
fbuf_free(&v->dec_out); |
| 1197 |
ast_free(v); |
| 1198 |
return NULL; |
| 1199 |
} |
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
static struct video_dec_desc *dec_init(uint32_t the_ast_format) |
| 1205 |
{ |
| 1206 |
enum CodecID codec; |
| 1207 |
struct video_dec_desc *v = ast_calloc(1, sizeof(*v)); |
| 1208 |
if (v == NULL) |
| 1209 |
return NULL; |
| 1210 |
|
| 1211 |
v->discard = 1; |
| 1212 |
|
| 1213 |
v->d_callbacks = map_video_codec(the_ast_format); |
| 1214 |
if (v->d_callbacks == NULL) { |
| 1215 |
ast_log(LOG_WARNING, "cannot find video codec, drop input 0x%x\n", the_ast_format); |
| 1216 |
return dec_uninit(v); |
| 1217 |
} |
| 1218 |
|
| 1219 |
codec = map_video_format(v->d_callbacks->format, CM_RD); |
| 1220 |
|
| 1221 |
v->codec = avcodec_find_decoder(codec); |
| 1222 |
if (!v->codec) { |
| 1223 |
ast_log(LOG_WARNING, "Unable to find the decoder for format %d\n", codec); |
| 1224 |
return dec_uninit(v); |
| 1225 |
} |
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
v->dec_ctx = avcodec_alloc_context(); |
| 1230 |
if (!v->dec_ctx) { |
| 1231 |
ast_log(LOG_WARNING, "Cannot allocate the decoder context\n"); |
| 1232 |
return dec_uninit(v); |
| 1233 |
} |
| 1234 |
|
| 1235 |
if (avcodec_open(v->dec_ctx, v->codec) < 0) { |
| 1236 |
ast_log(LOG_WARNING, "Cannot open the decoder context\n"); |
| 1237 |
av_free(v->dec_ctx); |
| 1238 |
v->dec_ctx = NULL; |
| 1239 |
return dec_uninit(v); |
| 1240 |
} |
| 1241 |
|
| 1242 |
v->parser = av_parser_init(codec); |
| 1243 |
if (!v->parser) { |
| 1244 |
ast_log(LOG_WARNING, "Cannot initialize the decoder parser\n"); |
| 1245 |
return dec_uninit(v); |
| 1246 |
} |
| 1247 |
|
| 1248 |
v->d_frame = avcodec_alloc_frame(); |
| 1249 |
if (!v->d_frame) { |
| 1250 |
ast_log(LOG_WARNING, "Cannot allocate decoding video frame\n"); |
| 1251 |
return dec_uninit(v); |
| 1252 |
} |
| 1253 |
v->dec_in_cur = &v->dec_in[0]; |
| 1254 |
v->dec_in_dpy = NULL; |
| 1255 |
|
| 1256 |
return v; |
| 1257 |
} |
| 1258 |
|