Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: source/patched-ffmpeg-mt/libavcodec/pthread.c

Issue 6588036: Merge 76138 - Properly account the thread index on all exit paths from the fu... (Closed) Base URL: svn://chrome-svn/chrome/branches/ffmpeg/648/
Patch Set: Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « patches/to_upstream/24_thread_index.patch ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 430 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 int thread_count = avctx->thread_count, err = 0; 441 int thread_count = avctx->thread_count, err = 0;
442 int returning_thread = fctx->next_finished; 442 int returning_thread = fctx->next_finished;
443 PerThreadContext *p; 443 PerThreadContext *p;
444 444
445 p = &fctx->threads[fctx->next_decoding]; 445 p = &fctx->threads[fctx->next_decoding];
446 update_thread_context_from_user(p->avctx, avctx); 446 update_thread_context_from_user(p->avctx, avctx);
447 err = submit_frame(p, avpkt); 447 err = submit_frame(p, avpkt);
448 if (err) return err; 448 if (err) return err;
449 449
450 fctx->next_decoding++; 450 fctx->next_decoding++;
451 int decoding_save = fctx->next_decoding;
452 if (fctx->next_decoding >= thread_count) fctx->next_decoding = 0;
451 453
452 if (fctx->delaying && avpkt->size) { 454 if (fctx->delaying && avpkt->size) {
453 if (fctx->next_decoding >= (thread_count-1)) fctx->delaying = 0; 455 if (decoding_save >= (thread_count-1)) fctx->delaying = 0;
454 456
455 *got_picture_ptr=0; 457 *got_picture_ptr=0;
456 return 0; 458 return 0;
457 } 459 }
458 460
459 //If it's draining frames at EOF, ignore null frames from the codec. 461 //If it's draining frames at EOF, ignore null frames from the codec.
460 //Only return one when we've run out of codec frames to return. 462 //Only return one when we've run out of codec frames to return.
461 do { 463 do {
462 p = &fctx->threads[returning_thread++]; 464 p = &fctx->threads[returning_thread++];
463 465
464 if (p->state != STATE_INPUT_READY) { 466 if (p->state != STATE_INPUT_READY) {
465 pthread_mutex_lock(&p->progress_mutex); 467 pthread_mutex_lock(&p->progress_mutex);
466 while (p->state != STATE_INPUT_READY) 468 while (p->state != STATE_INPUT_READY)
467 pthread_cond_wait(&p->output_cond, &p->progress_mutex); 469 pthread_cond_wait(&p->output_cond, &p->progress_mutex);
468 pthread_mutex_unlock(&p->progress_mutex); 470 pthread_mutex_unlock(&p->progress_mutex);
469 } 471 }
470 472
471 *picture = p->picture; 473 *picture = p->picture;
472 *got_picture_ptr = p->got_picture; 474 *got_picture_ptr = p->got_picture;
473 475
474 avcodec_get_frame_defaults(&p->picture); 476 avcodec_get_frame_defaults(&p->picture);
475 p->got_picture = 0; 477 p->got_picture = 0;
476 478
477 if (returning_thread >= thread_count) returning_thread = 0; 479 if (returning_thread >= thread_count) returning_thread = 0;
478 } while (!avpkt->size && !*got_picture_ptr && returning_thread != fctx->next _finished); 480 } while (!avpkt->size && !*got_picture_ptr && returning_thread != fctx->next _finished);
479 481
480 update_thread_context_from_copy(avctx, p->avctx, 1); 482 update_thread_context_from_copy(avctx, p->avctx, 1);
481 483
482 if (fctx->next_decoding >= thread_count) fctx->next_decoding = 0;
483 fctx->next_finished = returning_thread; 484 fctx->next_finished = returning_thread;
484 485
485 return p->result; 486 return p->result;
486 } 487 }
487 488
488 void ff_thread_report_progress(AVFrame *f, int n, int field) 489 void ff_thread_report_progress(AVFrame *f, int n, int field)
489 { 490 {
490 PerThreadContext *p; 491 PerThreadContext *p;
491 int *progress = f->thread_opaque; 492 int *progress = f->thread_opaque;
492 493
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
792 return 0; 793 return 0;
793 } 794 }
794 795
795 void avcodec_thread_free(AVCodecContext *avctx) 796 void avcodec_thread_free(AVCodecContext *avctx)
796 { 797 {
797 if (avctx->active_thread_type&FF_THREAD_FRAME) 798 if (avctx->active_thread_type&FF_THREAD_FRAME)
798 frame_thread_free(avctx, avctx->thread_count); 799 frame_thread_free(avctx, avctx->thread_count);
799 else 800 else
800 thread_free(avctx); 801 thread_free(avctx);
801 } 802 }
OLDNEW
« no previous file with comments | « patches/to_upstream/24_thread_index.patch ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698