~ubuntu-branches/ubuntu/oneiric/libav/oneiric

« back to all changes in this revision

Viewing changes to libavutil/pixdesc.c

  • Committer: Bazaar Package Importer
  • Author(s): Reinhard Tartler
  • Date: 2011-04-30 14:27:42 UTC
  • mfrom: (1.1.2 experimental)
  • Revision ID: james.westby@ubuntu.com-20110430142742-quvblxk1tj6adlh5
Tags: 4:0.7~b1-1ubuntu1
* Merge from debian. Remaining changes:
  - don't build against libfaad, libdirac, librtmp and libopenjpeg
    (all in universe)
  - explicitly --enable-pic on powerpc, cf. LP #654666
  - different arm configure bits that should probably better be
    merged into debian
* Cherry-picked from git: 
  - install doc/APIChanges and refer to them in NEWS.Debian (Closes: #623682)
  - don't try to install non-existing documentation, fixes FTBFS on powerpc

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * pixel format descriptor
3
3
 * Copyright (c) 2009 Michael Niedermayer <michaelni@gmx.at>
4
4
 *
5
 
 * This file is part of FFmpeg.
 
5
 * This file is part of Libav.
6
6
 *
7
 
 * FFmpeg is free software; you can redistribute it and/or
 
7
 * Libav is free software; you can redistribute it and/or
8
8
 * modify it under the terms of the GNU Lesser General Public
9
9
 * License as published by the Free Software Foundation; either
10
10
 * version 2.1 of the License, or (at your option) any later version.
11
11
 *
12
 
 * FFmpeg is distributed in the hope that it will be useful,
 
12
 * Libav is distributed in the hope that it will be useful,
13
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15
15
 * Lesser General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU Lesser General Public
18
 
 * License along with FFmpeg; if not, write to the Free Software
 
18
 * License along with Libav; if not, write to the Free Software
19
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
20
 */
21
21
 
 
22
#include <stdio.h>
 
23
#include <string.h>
22
24
#include "pixfmt.h"
23
25
#include "pixdesc.h"
24
26
 
25
27
#include "intreadwrite.h"
26
28
 
27
 
void read_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
28
 
               const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
 
29
void av_read_image_line(uint16_t *dst, const uint8_t *data[4], const int linesize[4],
 
30
                        const AVPixFmtDescriptor *desc, int x, int y, int c, int w, int read_pal_component)
29
31
{
30
32
    AVComponentDescriptor comp= desc->comp[c];
31
33
    int plane= comp.plane;
51
53
        }
52
54
    } else {
53
55
        const uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
 
56
        int is_8bit = shift + depth <= 8;
 
57
 
 
58
        if (is_8bit)
 
59
            p += !!(flags & PIX_FMT_BE);
54
60
 
55
61
        while(w--){
56
 
            int val;
57
 
            if(flags & PIX_FMT_BE) val= AV_RB16(p);
58
 
            else                   val= AV_RL16(p);
 
62
            int val = is_8bit ? *p :
 
63
                flags & PIX_FMT_BE ? AV_RB16(p) : AV_RL16(p);
59
64
            val = (val>>shift) & mask;
60
65
            if(read_pal_component)
61
66
                val= data[1][4*val + c];
65
70
    }
66
71
}
67
72
 
68
 
void write_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
69
 
                const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
 
73
void av_write_image_line(const uint16_t *src, uint8_t *data[4], const int linesize[4],
 
74
                         const AVPixFmtDescriptor *desc, int x, int y, int c, int w)
70
75
{
71
76
    AVComponentDescriptor comp = desc->comp[c];
72
77
    int plane = comp.plane;
89
94
        int shift = comp.shift;
90
95
        uint8_t *p = data[plane]+ y*linesize[plane] + x*step + comp.offset_plus1-1;
91
96
 
92
 
        while (w--) {
93
 
            if (flags & PIX_FMT_BE) {
94
 
                uint16_t val = AV_RB16(p) | (*src++<<shift);
95
 
                AV_WB16(p, val);
96
 
            } else {
97
 
                uint16_t val = AV_RL16(p) | (*src++<<shift);
98
 
                AV_WL16(p, val);
99
 
            }
100
 
            p+= step;
 
97
        if (shift + depth <= 8) {
 
98
            p += !!(flags & PIX_FMT_BE);
 
99
            while (w--) {
 
100
                *p |= (*src++<<shift);
 
101
                p += step;
 
102
            }
 
103
        } else {
 
104
            while (w--) {
 
105
                if (flags & PIX_FMT_BE) {
 
106
                    uint16_t val = AV_RB16(p) | (*src++<<shift);
 
107
                    AV_WB16(p, val);
 
108
                } else {
 
109
                    uint16_t val = AV_RL16(p) | (*src++<<shift);
 
110
                    AV_WL16(p, val);
 
111
                }
 
112
                p+= step;
 
113
            }
101
114
        }
102
115
    }
103
116
}
617
630
            {0,1,1,0,3},        /* B */
618
631
        },
619
632
    },
 
633
    [PIX_FMT_BGR48BE] = {
 
634
        .name = "bgr48be",
 
635
        .nb_components= 3,
 
636
        .log2_chroma_w= 0,
 
637
        .log2_chroma_h= 0,
 
638
        .comp = {
 
639
            {0,5,1,0,15},       /* B */
 
640
            {0,5,3,0,15},       /* G */
 
641
            {0,5,5,0,15},       /* R */
 
642
        },
 
643
        .flags = PIX_FMT_BE,
 
644
    },
 
645
    [PIX_FMT_BGR48LE] = {
 
646
        .name = "bgr48le",
 
647
        .nb_components= 3,
 
648
        .log2_chroma_w= 0,
 
649
        .log2_chroma_h= 0,
 
650
        .comp = {
 
651
            {0,5,1,0,15},       /* B */
 
652
            {0,5,3,0,15},       /* G */
 
653
            {0,5,5,0,15},       /* R */
 
654
        },
 
655
    },
620
656
    [PIX_FMT_BGR565BE] = {
621
657
        .name = "bgr565be",
622
658
        .nb_components= 3,
838
874
 
839
875
    return bits >> log2_pixels;
840
876
}
 
877
 
 
878
char *av_get_pix_fmt_string (char *buf, int buf_size, enum PixelFormat pix_fmt)
 
879
{
 
880
    /* print header */
 
881
    if (pix_fmt < 0) {
 
882
        snprintf (buf, buf_size, "name      " " nb_components" " nb_bits");
 
883
    } else {
 
884
        const AVPixFmtDescriptor *pixdesc = &av_pix_fmt_descriptors[pix_fmt];
 
885
        snprintf(buf, buf_size, "%-11s %7d %10d",
 
886
                 pixdesc->name, pixdesc->nb_components, av_get_bits_per_pixel(pixdesc));
 
887
    }
 
888
 
 
889
    return buf;
 
890
}