[FFmpeg-devel] Google Summer of Code participation
Michael Niedermayer
michaelni
Fri Apr 3 01:00:39 CEST 2009
On Fri, Apr 03, 2009 at 12:30:29AM +0200, Thilo Borgmann wrote:
> Unfortunately, I made a mistake in the last patch which moved the AVPacket
> struct to the wrong place in avcodec.h. I attached a patch to correct this
> (tb.movedAgainAVPacket.patch).
>
>
> The second patch I attached is for changing the AVCodec struct to contain a
> AVPacket*.
>
> I also changed every codec I could find. Now, each codec uses the
> appropriate pointer in its provided AVCodec struct. Next to this, a wrapper
> function decode_frame2() is introduced which passes the .data and .size
> attributes of the AVPacket to the existing decode_frame() function.
> I've respected any prefixes I've found.
> Unfortunately, some of the codecs use totally different names for the
> AVCodec struct than "[prefix]_decoder". I've found two of them,
> vapi_mpeg2.c and mlpdec.c. It might be that I've missed one! I looked over
> all files more than three times today (until I made my first git-based
> patch ever :) ) but double checking seems necessary to me.
>
> According to the change of the AVCodec struct, the corresponding decoding
> functions in libavcodec/utils.c have been wrapped like the decoding
> function of the coders.
> (there was an avcodec_decode_audio2() already, I wrapped this using
> avcodec_decode_audio3() - I don't know if this is correct of if I should
> have altered the existing ...2() ).
>
> I've successfully compiled my patched version using a git working copy
> cloned at 23:17 GMT+1.
> I've also get rid of any tab's as far as I can tell... maybe some made it
> into the patch, I appologize in advance.
>
> I would have posted this quite big patch to the list as a new topic using
> the [PATCH] prefix but since it requires the first attached patch to be
> applied before, I mail it here...
>
> TB
> diff --git a/libavcodec/4xm.c b/libavcodec/4xm.c
> index 5c96baa..26c7cce 100644
> --- a/libavcodec/4xm.c
> +++ b/libavcodec/4xm.c
> @@ -784,6 +784,15 @@ static int decode_frame(AVCodecContext *avctx,
> return buf_size;
> }
>
> +static int decode_frame2(AVCodecContext *avctx,
> + void *data, int *data_size,
> + AVPacket *avpkt)
> +{
> + return decode_frame(avctx, data, data_size, avpkt->data, avpkt->size);
> +}
> +
> +
> +
>
decode_frame() should be changed not a new one added.
[...]
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 4113382..eb732d2 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -530,12 +530,39 @@ int attribute_align_arg avcodec_decode_video(AVCodecContext *avctx, AVFrame *pic
> {
> int ret;
>
> + AVPacket avpkt;
> + avpkt.data = buf;
> + avpkt.size = buf_size;
> +
> *got_picture_ptr= 0;
> if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
> return -1;
> if((avctx->codec->capabilities & CODEC_CAP_DELAY) || buf_size){
> - ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
> - buf, buf_size);
> + ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
> + &avpkt);
> +
> + emms_c(); //needed to avoid an emms_c() call before every return;
indention if totally off
> +
> + if (*got_picture_ptr)
> + avctx->frame_number++;
> + }else
> + ret= 0;
> +
> + return ret;
> +}
> +
> +int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *picture,
> + int *got_picture_ptr,
> + AVPacket *avpkt)
> +{
> + int ret;
> +
> + *got_picture_ptr= 0;
> + if((avctx->coded_width||avctx->coded_height) && avcodec_check_dimensions(avctx,avctx->coded_width,avctx->coded_height))
> + return -1;
> + if((avctx->codec->capabilities & CODEC_CAP_DELAY) || avpkt->size){
> + ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
> + avpkt);
>
> emms_c(); //needed to avoid an emms_c() call before every return;
>
avcodec_decode_video() should call avcodec_decode_video2()
[...]
> diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
> index 8cedeb9..5f1ced7 100644
> --- a/libavcodec/avcodec.h
> +++ b/libavcodec/avcodec.h
> @@ -842,6 +842,55 @@ typedef struct AVPanScan{
> #define FF_BUFFER_HINTS_PRESERVE 0x04 // User must not alter buffer content.
> #define FF_BUFFER_HINTS_REUSABLE 0x08 // Codec will reuse the buffer (update).
>
> +typedef struct AVPacket {
> + /**
> + * Presentation timestamp in time_base units; the time at which the
> + * decompressed packet will be presented to the user.
> + * Can be AV_NOPTS_VALUE if it is not stored in the file.
> + * pts MUST be larger or equal to dts as presentation cannot happen before
> + * decompression, unless one wants to view hex dumps. Some formats misuse
> + * the terms dts and pts/cts to mean something different. Such timestamps
> + * must be converted to true pts/dts before they are stored in AVPacket.
> + */
> + int64_t pts;
> + /**
> + * Decompression timestamp in time_base units; the time at which the
> + * packet is decompressed.
> + * Can be AV_NOPTS_VALUE if it is not stored in the file.
> + */
> + int64_t dts;
> + uint8_t *data;
> + int size;
> + int stream_index;
> + int flags;
> + /**
> + * Duration of this packet in time_base units, 0 if unknown.
> + * Equals next_pts - this_pts in presentation order.
> + */
> + int duration;
> + void (*destruct)(struct AVPacket *);
> + void *priv;
> + int64_t pos; ///< byte position in stream, -1 if unknown
> +
> + /**
> + * Time difference in stream time base units from the pts of this
> + * packet to the point at which the output from the decoder has converged
> + * independent from the availability of previous frames. That is, the
> + * frames are virtually identical no matter if decoding started from
> + * the very first frame or from this keyframe.
> + * Is AV_NOPTS_VALUE if unknown.
> + * This field is not the display duration of the current packet.
> + *
> + * The purpose of this field is to allow seeking in streams that have no
> + * keyframes in the conventional sense. It corresponds to the
> + * recovery point SEI in H.264 and match_time_delta in NUT. It is also
> + * essential for some types of subtitle streams to ensure that all
> + * subtitles are correctly displayed after seeking.
> + */
> + int64_t convergence_duration;
> +} AVPacket;
> +#define PKT_FLAG_KEY 0x0001
> +
> /**
> * Audio Video Frame.
> * New fields can be added to the end of FF_COMMON_FRAME with minor version
> @@ -2526,55 +2575,6 @@ typedef struct AVPaletteControl {
> } AVPaletteControl attribute_deprecated;
> #endif
>
> -typedef struct AVPacket {
> - /**
> - * Presentation timestamp in time_base units; the time at which the
> - * decompressed packet will be presented to the user.
> - * Can be AV_NOPTS_VALUE if it is not stored in the file.
> - * pts MUST be larger or equal to dts as presentation cannot happen before
> - * decompression, unless one wants to view hex dumps. Some formats misuse
> - * the terms dts and pts/cts to mean something different. Such timestamps
> - * must be converted to true pts/dts before they are stored in AVPacket.
> - */
> - int64_t pts;
> - /**
> - * Decompression timestamp in time_base units; the time at which the
> - * packet is decompressed.
> - * Can be AV_NOPTS_VALUE if it is not stored in the file.
> - */
> - int64_t dts;
> - uint8_t *data;
> - int size;
> - int stream_index;
> - int flags;
> - /**
> - * Duration of this packet in time_base units, 0 if unknown.
> - * Equals next_pts - this_pts in presentation order.
> - */
> - int duration;
> - void (*destruct)(struct AVPacket *);
> - void *priv;
> - int64_t pos; ///< byte position in stream, -1 if unknown
> -
> - /**
> - * Time difference in stream time base units from the pts of this
> - * packet to the point at which the output from the decoder has converged
> - * independent from the availability of previous frames. That is, the
> - * frames are virtually identical no matter if decoding started from
> - * the very first frame or from this keyframe.
> - * Is AV_NOPTS_VALUE if unknown.
> - * This field is not the display duration of the current packet.
> - *
> - * The purpose of this field is to allow seeking in streams that have no
> - * keyframes in the conventional sense. It corresponds to the
> - * recovery point SEI in H.264 and match_time_delta in NUT. It is also
> - * essential for some types of subtitle streams to ensure that all
> - * subtitles are correctly displayed after seeking.
> - */
> - int64_t convergence_duration;
> -} AVPacket;
> -#define PKT_FLAG_KEY 0x0001
> -
> enum AVSubtitleType {
> SUBTITLE_NONE,
>
AVPacket move ok
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
I am the wisest man alive, for I know one thing, and that is that I know
nothing. -- Socrates
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20090403/1f5dd4ab/attachment.pgp>
More information about the ffmpeg-devel
mailing list