File:
[DVB] /
libsoftmpeg /
src /
video.h
Revision
1.15:
download - view:
text,
annotated -
select for diffs
Mon Jul 12 16:48:05 2004 UTC (19 years, 10 months ago) by
hunold
Branches:
MAIN
CVS tags:
HEAD
- remove individual xxx_handle_ts_packet() functions for audio and video
- handle ts packet filtering in softmpeg.c, do some sanity checks against payload_len
=> enhances stability on very broken reception
/*
(c) Copyright 2004 convergence GmbH
All rights reserved.
Written by Michael Hunold <hunold@convergence.de> and
Denis Oliver Kropp <dok@directfb.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the
Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef __SOFTMPEG__VIDEO_H__
#define __SOFTMPEG__VIDEO_H__
#include "internal.h"
//#define SOFTMPEG_DEBUG_VIDEO
#ifdef SOFTMPEG_DEBUG_VIDEO
#define VIDEO_DEBUG(x...) SOFTMPEG_DEBUG("Video: "x)
#else
#define VIDEO_DEBUG(x...) do {} while (0)
#endif
//#define SOFTMPEG_DEBUG_VIDEO_OUTPUT
#ifdef SOFTMPEG_DEBUG_VIDEO_OUTPUT
#define VIDEO_OUTPUT(x...) SOFTMPEG_DEBUG("Video output: "x)
#else
#define VIDEO_OUTPUT(x...) do {} while (0)
#endif
//#define SOFTMPEG_DEBUG_AVSYNC
#ifdef SOFTMPEG_DEBUG_AVSYNC
#define VIDEO_AVSYNC(x...) fprintf(stderr, x)
#else
#define VIDEO_AVSYNC(x...) do {} while (0)
#endif
struct video_frame {
int is_iframe;
unsigned int width;
unsigned int height;
float aspect_ratio;
unsigned char *data[4];
unsigned int linesize[4];
};
struct video_buffer {
struct list_element node;
/* "buf" holds one compressed mpeg video frame of "len" length */
unsigned char *buf;
unsigned int len;
uint64_t pts;
};
struct video_decoder;
struct video_codec
{
int (*init) (struct video_decoder *d);
int (*flush) (struct video_decoder *d);
int (*decode) (struct video_decoder *d, struct video_buffer *buf, struct video_frame *frame, int *ready);
};
struct video_operations
{
int (*init) (struct video_decoder *d, void *init_data, int *v_dura);
int (*resize) (struct video_decoder *d, unsigned int width, unsigned int height);
int (*clear) (struct video_decoder *d);
int (*prepare) (struct video_decoder *d, struct video_frame *frame);
int (*wait_for_sync)(struct video_decoder *d);
int (*flip) (struct video_decoder *d);
void *priv;
};
struct video_decoder {
/* back reference, needed so the sync code can access the audio status functions */
struct softmpeg_decoder *smd;
/* has this decoded decoded alredy decoded stuff? */
int used;
/* private pointer that will be passed to any callbacks */
void *priv;
/* width and height of the currently decoded picture */
int v_width;
int v_height;
/* are we synced to a frame? */
int synced_to_frame;
int initial_sync;
/* last video pts seen */
uint64_t l_pts;
/* our video buffers + the lists */
struct video_buffer output[NUMBER_OF_VIDEO_BUFFERS];
struct video_buffer *current;
struct list free;
struct list filled;
pthread_attr_t display_thread_attr;
pthread_t display_thread;
int display_thread_init;
pthread_attr_t decode_thread_attr;
pthread_t decode_thread;
int decode_thread_init;
/* cancel all video threads, mutex needed for syncronization */
int cancel_threads;
pthread_mutex_t mutex;
/* syncronization stuff between decode and display thread */
pthread_mutex_t backbuffer_mutex;
pthread_cond_t backbuffer_cond;
/* this gets signalled every time the backbuffer is filled again */
unsigned int backbuffer_filled;
/* 0 ok, +1 hurry up, -1 slow down */
int sync_correction;
/* for free flowing video display */
int av_sync_disable;
struct video_operations *v_ops;
int v_dura;
struct video_codec *v_codec;
};
struct video_decoder *video_decoder_create(void *priv, struct softmpeg_decoder *dec, enum softmpeg_video_output vo, void *v_init_data);
int video_decoder_destroy(struct video_decoder *d);
int video_handle_pes_data(struct video_decoder *d, const unsigned char *payload, const unsigned int payload_len, int ptsdts_updated, uint64_t pts);
int video_flush_queue(struct video_decoder *d);
int video_set_pause(struct video_decoder *d, int paused);
#endif
LinuxTV legacy CVS <linuxtv.org/cvs>