| 306 | } |
| 307 | |
| 308 | int decavsubWork( hb_decavsub_context_t * ctx, |
| 309 | hb_buffer_t ** buf_in, |
| 310 | hb_buffer_t ** buf_out ) |
| 311 | { |
| 312 | hb_buffer_t * in = *buf_in; |
| 313 | hb_buffer_settings_t in_s = in->s; |
| 314 | |
| 315 | if (in_s.flags & HB_BUF_FLAG_EOF) |
| 316 | { |
| 317 | /* EOF on input stream - send it downstream & say that we're done */ |
| 318 | *buf_in = NULL; |
| 319 | hb_buffer_list_append(&ctx->list, in); |
| 320 | |
| 321 | *buf_out = hb_buffer_list_clear(&ctx->list); |
| 322 | return HB_WORK_DONE; |
| 323 | } |
| 324 | |
| 325 | if (!ctx->job->indepth_scan && |
| 326 | !hb_subtitle_must_burn(ctx->subtitle, ctx->job->mux)) |
| 327 | { |
| 328 | // Append to buffer list. It will be sent to fifo after we determine |
| 329 | // if this is a packet we need. |
| 330 | hb_buffer_list_append(&ctx->list_pass, in); |
| 331 | |
| 332 | // We are keeping the buffer, so prevent the filter loop from |
| 333 | // deleting it. |
| 334 | *buf_in = NULL; |
| 335 | } |
| 336 | |
| 337 | AVSubtitle subtitle; |
| 338 | memset( &subtitle, 0, sizeof(subtitle) ); |
| 339 | |
| 340 | int64_t duration = AV_NOPTS_VALUE; |
| 341 | |
| 342 | ctx->pkt->data = in->data; |
| 343 | ctx->pkt->size = in->size; |
| 344 | ctx->pkt->pts = in_s.start; |
| 345 | if (in_s.duration > 0 || ctx->subtitle->source == SSASUB || ctx->subtitle->source == IMPORTSSA) |
| 346 | { |
| 347 | duration = in_s.duration; |
| 348 | } |
| 349 | |
| 350 | if (duration <= 0 && |
| 351 | in_s.start != AV_NOPTS_VALUE && |
| 352 | in_s.stop != AV_NOPTS_VALUE && |
| 353 | in_s.stop > in_s.start) |
| 354 | { |
| 355 | duration = in_s.stop - in_s.start; |
| 356 | } |
| 357 | |
| 358 | int has_subtitle = 0; |
| 359 | |
| 360 | while (ctx->pkt->size > 0) |
| 361 | { |
| 362 | int usedBytes = avcodec_decode_subtitle2(ctx->context, &subtitle, |
| 363 | &has_subtitle, ctx->pkt ); |
| 364 | if (usedBytes < 0) |
| 365 | { |
no test coverage detected