Revision b4d00c20

View differences:

libavcodec/truemotion1.c
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 473
//    else
475 474
//        avctx->pix_fmt = PIX_FMT_RGB555;
476 475

  
477
    s->frame.data[0] = s->prev_frame.data[0] = NULL;
476
    s->frame.data[0] = NULL;
478 477

  
479 478
    /* there is a vertical predictor for each pixel in a line; each vertical
480 479
     * predictor is 0 to start with */
......
590 589

  
591 590
#define OUTPUT_PIXEL_PAIR() \
592 591
    *current_pixel_pair = *vert_pred + horiz_pred; \
593
    *vert_pred++ = *current_pixel_pair++; \
594
    prev_pixel_pair++;
592
    *vert_pred++ = *current_pixel_pair++;
595 593

  
596 594
static void truemotion1_decode_16bit(TrueMotion1Context *s)
597 595
{
......
601 599
    unsigned int horiz_pred;
602 600
    unsigned int *vert_pred;
603 601
    unsigned int *current_pixel_pair;
604
    unsigned int *prev_pixel_pair;
605 602
    unsigned char *current_line = s->frame.data[0];
606
    unsigned char *prev_line = s->prev_frame.data[0];
607 603
    int keyframe = s->flags & FLAG_KEYFRAME;
608 604

  
609 605
    /* these variables are for managing the stream of macroblock change bits */
......
626 622
        /* re-init variables for the next line iteration */
627 623
        horiz_pred = 0;
628 624
        current_pixel_pair = (unsigned int *)current_line;
629
        prev_pixel_pair = (unsigned int *)prev_line;
630 625
        vert_pred = s->vert_pred;
631 626
        mb_change_index = 0;
632 627
        mb_change_byte = mb_change_bits[mb_change_index++];
......
695 690

  
696 691
                /* skip (copy) four pixels, but reassign the horizontal
697 692
                 * predictor */
698
                *current_pixel_pair = *prev_pixel_pair++;
699 693
                *vert_pred++ = *current_pixel_pair++;
700
                *current_pixel_pair = *prev_pixel_pair++;
701 694
                horiz_pred = *current_pixel_pair - *vert_pred;
702 695
                *vert_pred++ = *current_pixel_pair++;
703 696

  
......
721 714
            mb_change_bits += s->mb_change_bits_row_size;
722 715

  
723 716
        current_line += s->frame.linesize[0];
724
        prev_line += s->prev_frame.linesize[0];
725 717
    }
726 718
}
727 719

  
......
733 725
    unsigned int horiz_pred;
734 726
    unsigned int *vert_pred;
735 727
    unsigned int *current_pixel_pair;
736
    unsigned int *prev_pixel_pair;
737 728
    unsigned char *current_line = s->frame.data[0];
738
    unsigned char *prev_line = s->prev_frame.data[0];
739 729
    int keyframe = s->flags & FLAG_KEYFRAME;
740 730

  
741 731
    /* these variables are for managing the stream of macroblock change bits */
......
758 748
        /* re-init variables for the next line iteration */
759 749
        horiz_pred = 0;
760 750
        current_pixel_pair = (unsigned int *)current_line;
761
        prev_pixel_pair = (unsigned int *)prev_line;
762 751
        vert_pred = s->vert_pred;
763 752
        mb_change_index = 0;
764 753
        mb_change_byte = mb_change_bits[mb_change_index++];
......
827 816

  
828 817
                /* skip (copy) four pixels, but reassign the horizontal
829 818
                 * predictor */
830
                *current_pixel_pair = *prev_pixel_pair++;
831 819
                *vert_pred++ = *current_pixel_pair++;
832
                *current_pixel_pair = *prev_pixel_pair++;
833 820
                horiz_pred = *current_pixel_pair - *vert_pred;
834 821
                *vert_pred++ = *current_pixel_pair++;
835 822

  
......
853 840
            mb_change_bits += s->mb_change_bits_row_size;
854 841

  
855 842
        current_line += s->frame.linesize[0];
856
        prev_line += s->prev_frame.linesize[0];
857 843
    }
858 844
}
859 845

  
......
871 857
        return -1;
872 858

  
873 859
    s->frame.reference = 1;
874
    if (avctx->get_buffer(avctx, &s->frame) < 0) {
860
    s->frame.buffer_hints = FF_BUFFER_HINTS_VALID |
861
        FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
862
    if (avctx->reget_buffer(avctx, &s->frame) < 0) {
875 863
        av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed\n");
876 864
        return -1;
877 865
    }
878 866

  
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) {
867
    if (compression_types[s->compression].algorithm == ALGO_RGB24H) {
885 868
        truemotion1_decode_24bit(s);
886
    } else {
869
    } else if (compression_types[s->compression].algorithm != ALGO_NOP) {
887 870
        truemotion1_decode_16bit(s);
888 871
    }
889 872

  
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 873
    *data_size = sizeof(AVFrame);
897 874
    *(AVFrame*)data = s->frame;
898 875

  
......
904 881
{
905 882
    TrueMotion1Context *s = avctx->priv_data;
906 883

  
907
    /* release the last frame */
908
    if (s->prev_frame.data[0])
909
        avctx->release_buffer(avctx, &s->prev_frame);
884
    if (s->frame.data[0])
885
        avctx->release_buffer(avctx, &s->frame);
910 886

  
911 887
    av_free(s->vert_pred);
912 888

  

Also available in: Unified diff