Originally committed as revision 10000 to svn://svn.ffmpeg.org/ffmpeg/trunk
Alex Beregszaszi authored on 2007/08/09 09:16:27... | ... |
@@ -42,7 +42,6 @@ |
42 | 42 |
typedef struct TrueMotion1Context { |
43 | 43 |
AVCodecContext *avctx; |
44 | 44 |
AVFrame frame; |
45 |
- AVFrame prev_frame; |
|
46 | 45 |
|
47 | 46 |
uint8_t *buf; |
48 | 47 |
int size; |
... | ... |
@@ -474,7 +473,7 @@ static int truemotion1_decode_init(AVCodecContext *avctx) |
474 | 474 |
// else |
475 | 475 |
// avctx->pix_fmt = PIX_FMT_RGB555; |
476 | 476 |
|
477 |
- s->frame.data[0] = s->prev_frame.data[0] = NULL; |
|
477 |
+ s->frame.data[0] = NULL; |
|
478 | 478 |
|
479 | 479 |
/* there is a vertical predictor for each pixel in a line; each vertical |
480 | 480 |
* predictor is 0 to start with */ |
... | ... |
@@ -590,8 +589,7 @@ hres,vres,i,i%vres (0 < i < 4) |
590 | 590 |
|
591 | 591 |
#define OUTPUT_PIXEL_PAIR() \ |
592 | 592 |
*current_pixel_pair = *vert_pred + horiz_pred; \ |
593 |
- *vert_pred++ = *current_pixel_pair++; \ |
|
594 |
- prev_pixel_pair++; |
|
593 |
+ *vert_pred++ = *current_pixel_pair++; |
|
595 | 594 |
|
596 | 595 |
static void truemotion1_decode_16bit(TrueMotion1Context *s) |
597 | 596 |
{ |
... | ... |
@@ -601,9 +599,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) |
601 | 601 |
unsigned int horiz_pred; |
602 | 602 |
unsigned int *vert_pred; |
603 | 603 |
unsigned int *current_pixel_pair; |
604 |
- unsigned int *prev_pixel_pair; |
|
605 | 604 |
unsigned char *current_line = s->frame.data[0]; |
606 |
- unsigned char *prev_line = s->prev_frame.data[0]; |
|
607 | 605 |
int keyframe = s->flags & FLAG_KEYFRAME; |
608 | 606 |
|
609 | 607 |
/* these variables are for managing the stream of macroblock change bits */ |
... | ... |
@@ -626,7 +622,6 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) |
626 | 626 |
/* re-init variables for the next line iteration */ |
627 | 627 |
horiz_pred = 0; |
628 | 628 |
current_pixel_pair = (unsigned int *)current_line; |
629 |
- prev_pixel_pair = (unsigned int *)prev_line; |
|
630 | 629 |
vert_pred = s->vert_pred; |
631 | 630 |
mb_change_index = 0; |
632 | 631 |
mb_change_byte = mb_change_bits[mb_change_index++]; |
... | ... |
@@ -695,9 +690,7 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) |
695 | 695 |
|
696 | 696 |
/* skip (copy) four pixels, but reassign the horizontal |
697 | 697 |
* predictor */ |
698 |
- *current_pixel_pair = *prev_pixel_pair++; |
|
699 | 698 |
*vert_pred++ = *current_pixel_pair++; |
700 |
- *current_pixel_pair = *prev_pixel_pair++; |
|
701 | 699 |
horiz_pred = *current_pixel_pair - *vert_pred; |
702 | 700 |
*vert_pred++ = *current_pixel_pair++; |
703 | 701 |
|
... | ... |
@@ -721,7 +714,6 @@ static void truemotion1_decode_16bit(TrueMotion1Context *s) |
721 | 721 |
mb_change_bits += s->mb_change_bits_row_size; |
722 | 722 |
|
723 | 723 |
current_line += s->frame.linesize[0]; |
724 |
- prev_line += s->prev_frame.linesize[0]; |
|
725 | 724 |
} |
726 | 725 |
} |
727 | 726 |
|
... | ... |
@@ -733,9 +725,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) |
733 | 733 |
unsigned int horiz_pred; |
734 | 734 |
unsigned int *vert_pred; |
735 | 735 |
unsigned int *current_pixel_pair; |
736 |
- unsigned int *prev_pixel_pair; |
|
737 | 736 |
unsigned char *current_line = s->frame.data[0]; |
738 |
- unsigned char *prev_line = s->prev_frame.data[0]; |
|
739 | 737 |
int keyframe = s->flags & FLAG_KEYFRAME; |
740 | 738 |
|
741 | 739 |
/* these variables are for managing the stream of macroblock change bits */ |
... | ... |
@@ -758,7 +748,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) |
758 | 758 |
/* re-init variables for the next line iteration */ |
759 | 759 |
horiz_pred = 0; |
760 | 760 |
current_pixel_pair = (unsigned int *)current_line; |
761 |
- prev_pixel_pair = (unsigned int *)prev_line; |
|
762 | 761 |
vert_pred = s->vert_pred; |
763 | 762 |
mb_change_index = 0; |
764 | 763 |
mb_change_byte = mb_change_bits[mb_change_index++]; |
... | ... |
@@ -827,9 +816,7 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) |
827 | 827 |
|
828 | 828 |
/* skip (copy) four pixels, but reassign the horizontal |
829 | 829 |
* predictor */ |
830 |
- *current_pixel_pair = *prev_pixel_pair++; |
|
831 | 830 |
*vert_pred++ = *current_pixel_pair++; |
832 |
- *current_pixel_pair = *prev_pixel_pair++; |
|
833 | 831 |
horiz_pred = *current_pixel_pair - *vert_pred; |
834 | 832 |
*vert_pred++ = *current_pixel_pair++; |
835 | 833 |
|
... | ... |
@@ -853,7 +840,6 @@ static void truemotion1_decode_24bit(TrueMotion1Context *s) |
853 | 853 |
mb_change_bits += s->mb_change_bits_row_size; |
854 | 854 |
|
855 | 855 |
current_line += s->frame.linesize[0]; |
856 |
- prev_line += s->prev_frame.linesize[0]; |
|
857 | 856 |
} |
858 | 857 |
} |
859 | 858 |
|
... | ... |
@@ -871,28 +857,19 @@ static int truemotion1_decode_frame(AVCodecContext *avctx, |
871 | 871 |
return -1; |
872 | 872 |
|
873 | 873 |
s->frame.reference = 1; |
874 |
- if (avctx->get_buffer(avctx, &s->frame) < 0) { |
|
874 |
+ s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | |
|
875 |
+ FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE; |
|
876 |
+ if (avctx->reget_buffer(avctx, &s->frame) < 0) { |
|
875 | 877 |
av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n"); |
876 | 878 |
return -1; |
877 | 879 |
} |
878 | 880 |
|
879 |
- /* check for a do-nothing frame and copy the previous frame */ |
|
880 |
- if (compression_types[s->compression].algorithm == ALGO_NOP) |
|
881 |
- { |
|
882 |
- memcpy(s->frame.data[0], s->prev_frame.data[0], |
|
883 |
- s->frame.linesize[0] * s->avctx->height); |
|
884 |
- } else if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
|
881 |
+ if (compression_types[s->compression].algorithm == ALGO_RGB24H) { |
|
885 | 882 |
truemotion1_decode_24bit(s); |
886 |
- } else { |
|
883 |
+ } else if (compression_types[s->compression].algorithm != ALGO_NOP) { |
|
887 | 884 |
truemotion1_decode_16bit(s); |
888 | 885 |
} |
889 | 886 |
|
890 |
- if (s->prev_frame.data[0]) |
|
891 |
- avctx->release_buffer(avctx, &s->prev_frame); |
|
892 |
- |
|
893 |
- /* shuffle frames */ |
|
894 |
- s->prev_frame = s->frame; |
|
895 |
- |
|
896 | 887 |
*data_size = sizeof(AVFrame); |
897 | 888 |
*(AVFrame*)data = s->frame; |
898 | 889 |
|
... | ... |
@@ -904,9 +881,8 @@ static int truemotion1_decode_end(AVCodecContext *avctx) |
904 | 904 |
{ |
905 | 905 |
TrueMotion1Context *s = avctx->priv_data; |
906 | 906 |
|
907 |
- /* release the last frame */ |
|
908 |
- if (s->prev_frame.data[0]) |
|
909 |
- avctx->release_buffer(avctx, &s->prev_frame); |
|
907 |
+ if (s->frame.data[0]) |
|
908 |
+ avctx->release_buffer(avctx, &s->frame); |
|
910 | 909 |
|
911 | 910 |
av_free(s->vert_pred); |
912 | 911 |
|