Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4349 Serge 1
/*
2
 * Copyright (c) 2008 BBC, Anuradha Suraparaju 
3
 *
4
 * This file is part of FFmpeg.
5
 *
6
 * FFmpeg is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU Lesser General Public
8
 * License as published by the Free Software Foundation; either
9
 * version 2.1 of the License, or (at your option) any later version.
10
 *
11
 * FFmpeg is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * Lesser General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU Lesser General Public
17
 * License along with FFmpeg; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
 */
20
 
21
/**
22
* @file
23
* data structures common to libschroedinger decoder and encoder
24
*/
25
 
26
#ifndef AVCODEC_LIBSCHROEDINGER_H
27
#define AVCODEC_LIBSCHROEDINGER_H
28
 
29
#include 
30
#include 
31
 
32
#include "avcodec.h"
33
 
34
typedef struct SchroVideoFormatInfo {
35
    uint16_t width;
36
    uint16_t height;
37
    uint16_t frame_rate_num;
38
    uint16_t frame_rate_denom;
39
} SchroVideoFormatInfo;
40
 
41
/**
42
* contains a single encoded frame returned from Dirac or Schroedinger
43
*/
44
typedef struct FFSchroEncodedFrame {
45
    /** encoded frame data */
46
    uint8_t *p_encbuf;
47
 
48
    /** encoded frame size */
49
    uint32_t size;
50
 
51
    /** encoded frame number. Will be used as pts */
52
    uint32_t frame_num;
53
 
54
    /** key frame flag. 1 : is key frame , 0 : in not key frame */
55
    uint16_t key_frame;
56
} FFSchroEncodedFrame;
57
 
58
/**
59
* queue element
60
*/
61
typedef struct FFSchroQueueElement {
62
    /** Data to be stored in queue*/
63
    void *data;
64
    /** Pointer to next element queue */
65
    struct FFSchroQueueElement *next;
66
} FFSchroQueueElement;
67
 
68
 
69
/**
70
* A simple queue implementation used in libschroedinger
71
*/
72
typedef struct FFSchroQueue {
73
    /** Pointer to head of queue */
74
    FFSchroQueueElement *p_head;
75
    /** Pointer to tail of queue */
76
    FFSchroQueueElement *p_tail;
77
    /** Queue size*/
78
    int size;
79
} FFSchroQueue;
80
 
81
/**
82
* Initialise the queue
83
*/
84
void ff_schro_queue_init(FFSchroQueue *queue);
85
 
86
/**
87
* Add an element to the end of the queue
88
*/
89
int ff_schro_queue_push_back(FFSchroQueue *queue, void *p_data);
90
 
91
/**
92
* Return the first element in the queue
93
*/
94
void *ff_schro_queue_pop(FFSchroQueue *queue);
95
 
96
/**
97
* Free the queue resources. free_func is a function supplied by the caller to
98
* free any resources allocated by the caller. The data field of the queue
99
* element is passed to it.
100
*/
101
void ff_schro_queue_free(FFSchroQueue *queue, void (*free_func)(void *));
102
 
103
static const struct {
104
    enum AVPixelFormat  ff_pix_fmt;
105
    SchroChromaFormat schro_pix_fmt;
106
    SchroFrameFormat  schro_frame_fmt;
107
} schro_pixel_format_map[] = {
108
    { AV_PIX_FMT_YUV420P, SCHRO_CHROMA_420, SCHRO_FRAME_FORMAT_U8_420 },
109
    { AV_PIX_FMT_YUV422P, SCHRO_CHROMA_422, SCHRO_FRAME_FORMAT_U8_422 },
110
    { AV_PIX_FMT_YUV444P, SCHRO_CHROMA_444, SCHRO_FRAME_FORMAT_U8_444 },
111
};
112
 
113
/**
114
* Returns the video format preset matching the input video dimensions and
115
* time base.
116
*/
117
SchroVideoFormatEnum ff_get_schro_video_format_preset (AVCodecContext *avctx);
118
 
119
/**
120
* Sets the Schroedinger frame format corresponding to the Schro chroma format
121
* passed. Returns 0 on success, -1 on failure.
122
*/
123
int ff_get_schro_frame_format(SchroChromaFormat schro_chroma_fmt,
124
                              SchroFrameFormat  *schro_frame_fmt);
125
 
126
/**
127
* Create a Schro frame based on the dimensions and frame format
128
* passed. Returns a pointer to a frame on success, NULL on failure.
129
*/
130
SchroFrame *ff_create_schro_frame(AVCodecContext *avctx,
131
                                  SchroFrameFormat schro_frame_fmt);
132
 
133
#endif /* AVCODEC_LIBSCHROEDINGER_H */