~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/avi/intern/rgb32.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 *
3
 
 * This is external code. Converts between rgb32 and avi.
4
 
 *
5
 
 * ***** BEGIN GPL LICENSE BLOCK *****
6
 
 *
7
 
 * This program is free software; you can redistribute it and/or
8
 
 * modify it under the terms of the GNU General Public License
9
 
 * as published by the Free Software Foundation; either version 2
10
 
 * of the License, or (at your option) any later version.
11
 
 *
12
 
 * This program is distributed in the hope that it will be useful,
13
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
 * GNU General Public License for more details.
16
 
 *
17
 
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software Foundation,
19
 
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 
 *
21
 
 * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
22
 
 * All rights reserved.
23
 
 *
24
 
 * The Original Code is: all of this file.
25
 
 *
26
 
 * Contributor(s): none yet.
27
 
 *
28
 
 * ***** END GPL LICENSE BLOCK *****
29
 
 *
30
 
 */
31
 
 
32
 
/** \file blender/avi/intern/rgb32.c
33
 
 *  \ingroup avi
34
 
 */
35
 
 
36
 
 
37
 
#include "AVI_avi.h"
38
 
#include <stdlib.h>
39
 
#include <string.h>
40
 
#include "MEM_guardedalloc.h"
41
 
#include "rgb32.h"
42
 
 
43
 
void *avi_converter_from_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
44
 
{
45
 
        int y, x, rowstridea, rowstrideb;
46
 
        unsigned char *buf;
47
 
 
48
 
        (void)stream; /* unused */
49
 
 
50
 
        buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromrgb32buf");
51
 
        *size = movie->header->Height * movie->header->Width * 3;
52
 
 
53
 
        rowstridea = movie->header->Width*3;
54
 
        rowstrideb = movie->header->Width*4;
55
 
 
56
 
        for (y=0; y < movie->header->Height; y++) {
57
 
                for (x=0; x < movie->header->Width; x++) {
58
 
                        buf[y*rowstridea + x*3 + 0] = buffer[y*rowstrideb + x*4 + 3];
59
 
                        buf[y*rowstridea + x*3 + 1] = buffer[y*rowstrideb + x*4 + 2];
60
 
                        buf[y*rowstridea + x*3 + 2] = buffer[y*rowstrideb + x*4 + 1];
61
 
                }
62
 
        }
63
 
 
64
 
        MEM_freeN (buffer);
65
 
 
66
 
        return buf;
67
 
}
68
 
 
69
 
void *avi_converter_to_rgb32 (AviMovie *movie, int stream, unsigned char *buffer, int *size)
70
 
{
71
 
        int i;
72
 
        unsigned char *buf;
73
 
        unsigned char *to, *from;
74
 
 
75
 
        (void)stream; /* unused */
76
 
 
77
 
        buf= MEM_mallocN (movie->header->Height * movie->header->Width * 4, "torgb32buf");
78
 
        *size= movie->header->Height * movie->header->Width * 4;
79
 
 
80
 
        memset(buf, 255, *size);
81
 
 
82
 
        to= buf; from= buffer;
83
 
        i=movie->header->Height*movie->header->Width;
84
 
        
85
 
        while (i--) {
86
 
                memcpy(to, from, 3);
87
 
                to+=4; from+=3;
88
 
        }
89
 
 
90
 
        MEM_freeN (buffer);
91
 
 
92
 
        return buf;
93
 
}