OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 Roman Shaposhnik | 2 * Copyright (c) 2004 Roman Shaposhnik |
3 * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com) | 3 * Copyright (c) 2008 Alexander Strange (astrange@ithinksw.com) |
4 * | 4 * |
5 * Many thanks to Steven M. Schultz for providing clever ideas and | 5 * Many thanks to Steven M. Schultz for providing clever ideas and |
6 * to Michael Niedermayer <michaelni@gmx.at> for writing initial | 6 * to Michael Niedermayer <michaelni@gmx.at> for writing initial |
7 * implementation. | 7 * implementation. |
8 * | 8 * |
9 * This file is part of FFmpeg. | 9 * This file is part of FFmpeg. |
10 * | 10 * |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 if (p->state == STATE_GET_BUFFER) { | 478 if (p->state == STATE_GET_BUFFER) { |
479 p->result = p->avctx->get_buffer(p->avctx, p->requested_frame); | 479 p->result = p->avctx->get_buffer(p->avctx, p->requested_frame); |
480 p->state = STATE_SETTING_UP; | 480 p->state = STATE_SETTING_UP; |
481 pthread_cond_signal(&p->progress_cond); | 481 pthread_cond_signal(&p->progress_cond); |
482 } | 482 } |
483 pthread_mutex_unlock(&p->progress_mutex); | 483 pthread_mutex_unlock(&p->progress_mutex); |
484 } | 484 } |
485 } | 485 } |
486 | 486 |
487 fctx->prev_thread = p; | 487 fctx->prev_thread = p; |
| 488 fctx->next_decoding++; |
488 | 489 |
489 return 0; | 490 return 0; |
490 } | 491 } |
491 | 492 |
492 int ff_thread_decode_frame(AVCodecContext *avctx, | 493 int ff_thread_decode_frame(AVCodecContext *avctx, |
493 AVFrame *picture, int *got_picture_ptr, | 494 AVFrame *picture, int *got_picture_ptr, |
494 AVPacket *avpkt) | 495 AVPacket *avpkt) |
495 { | 496 { |
496 FrameThreadContext *fctx = avctx->thread_opaque; | 497 FrameThreadContext *fctx = avctx->thread_opaque; |
497 int finished = fctx->next_finished; | 498 int finished = fctx->next_finished; |
498 PerThreadContext *p; | 499 PerThreadContext *p; |
499 int err; | 500 int err; |
500 | 501 |
501 /* | 502 /* |
502 * Submit a packet to the next decoding thread. | 503 * Submit a packet to the next decoding thread. |
503 */ | 504 */ |
504 | 505 |
505 p = &fctx->threads[fctx->next_decoding]; | 506 p = &fctx->threads[fctx->next_decoding]; |
506 update_context_from_user(p->avctx, avctx); | 507 update_context_from_user(p->avctx, avctx); |
507 err = submit_packet(p, avpkt); | 508 err = submit_packet(p, avpkt); |
508 if (err) return err; | 509 if (err) return err; |
509 | 510 |
510 fctx->next_decoding++; | |
511 | |
512 /* | 511 /* |
513 * If we're still receiving the initial packets, don't return a frame. | 512 * If we're still receiving the initial packets, don't return a frame. |
514 */ | 513 */ |
515 | 514 |
516 if (fctx->delaying && avpkt->size) { | 515 if (fctx->delaying && avpkt->size) { |
517 if (fctx->next_decoding >= (avctx->thread_count-1)) fctx->delaying = 0; | 516 if (fctx->next_decoding >= (avctx->thread_count-1)) fctx->delaying = 0; |
518 | 517 |
519 *got_picture_ptr=0; | 518 *got_picture_ptr=0; |
520 return 0; | 519 return 0; |
521 } | 520 } |
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 return 0; | 909 return 0; |
911 } | 910 } |
912 | 911 |
913 void ff_thread_free(AVCodecContext *avctx) | 912 void ff_thread_free(AVCodecContext *avctx) |
914 { | 913 { |
915 if (avctx->active_thread_type&FF_THREAD_FRAME) | 914 if (avctx->active_thread_type&FF_THREAD_FRAME) |
916 frame_thread_free(avctx, avctx->thread_count); | 915 frame_thread_free(avctx, avctx->thread_count); |
917 else | 916 else |
918 thread_free(avctx); | 917 thread_free(avctx); |
919 } | 918 } |
OLD | NEW |