[xiph-commits] r12912 - in trunk/theora-exp: examples
include/theora lib
tterribe at svn.xiph.org
tterribe at svn.xiph.org
Wed May 2 21:22:08 PDT 2007
Author: tterribe
Date: 2007-05-02 21:22:07 -0700 (Wed, 02 May 2007)
New Revision: 12912
Modified:
trunk/theora-exp/examples/dump_video.c
trunk/theora-exp/examples/encoder_example.c
trunk/theora-exp/examples/player_example.c
trunk/theora-exp/include/theora/codec.h
trunk/theora-exp/include/theora/theoradec.h
trunk/theora-exp/include/theora/theoraenc.h
trunk/theora-exp/lib/apiwrapper.c
trunk/theora-exp/lib/decinfo.c
trunk/theora-exp/lib/decint.h
trunk/theora-exp/lib/decode.c
trunk/theora-exp/lib/dequant.c
trunk/theora-exp/lib/dequant.h
trunk/theora-exp/lib/encinfo.c
trunk/theora-exp/lib/encint.h
trunk/theora-exp/lib/encode.c
trunk/theora-exp/lib/encvbr.c
trunk/theora-exp/lib/encvbr.h
trunk/theora-exp/lib/enquant.c
trunk/theora-exp/lib/enquant.h
trunk/theora-exp/lib/fragment.c
trunk/theora-exp/lib/impmap.c
trunk/theora-exp/lib/internal.c
trunk/theora-exp/lib/internal.h
trunk/theora-exp/lib/ocintrin.h
trunk/theora-exp/lib/quant.c
trunk/theora-exp/lib/state.c
Log:
General tree cleanup.
Cleans up the spacing and alignment mess after the theora_->th_ conversion.
Warning fixes for gcc.
These latter uncovered one real bug in apiwrapper, where theora_decode_init()
was not returning a value.
It now returns an error code if it cannot initialize the decoder (usually
because the parameters in the th_info structure were somehow invalid).
Also updates the decoder version checking to follow the scheme laid out in the
specification.
Modified: trunk/theora-exp/examples/dump_video.c
===================================================================
--- trunk/theora-exp/examples/dump_video.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/examples/dump_video.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -18,10 +18,21 @@
/* By Mauricio Piacentini (mauricio at xiph.org) */
/* simply dump decoded YUV data, for verification of theora bitstream */
+#if !defined(_REENTRANT)
+#define _REENTRANT
+#endif
+#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
+#endif
+#if !defined(_LARGEFILE_SOURCE)
#define _LARGEFILE_SOURCE
+#endif
+#if !defined(_LARGEFILE64_SOURCE)
#define _LARGEFILE64_SOURCE
+#endif
+#if !defined(_FILE_OFFSET_BITS)
#define _FILE_OFFSET_BITS 64
+#endif
#include <stdio.h>
#include <unistd.h>
@@ -63,10 +74,10 @@
ogg_page og;
ogg_stream_state vo;
ogg_stream_state to;
-th_info ti;
-th_comment tc;
-th_setup_info *ts;
-th_dec_ctx *td;
+th_info ti;
+th_comment tc;
+th_setup_info *ts;
+th_dec_ctx *td;
int theora_p=0;
int theora_processing_headers;
@@ -105,7 +116,7 @@
static void open_video(void){
th_stripe_callback cb;
- int pli;
+ int pli;
/*Here we allocate a buffer so we can use the striped decode feature.
There's no real reason to do this in this application, because we want to
write to the file top-down, but the frame gets decoded bottom up, so we
@@ -194,25 +205,25 @@
switch(c){
case 'o':
if(!strcmp(optarg,"-")){
- outfile=fopen(optarg,"wb");
- if(outfile==NULL){
- fprintf(stderr,"Unable to open output file '%s'\n", optarg);
- exit(1);
- }
+ outfile=fopen(optarg,"wb");
+ if(outfile==NULL){
+ fprintf(stderr,"Unable to open output file '%s'\n", optarg);
+ exit(1);
+ }
}else{
- outfile=stdout;
+ outfile=stdout;
}
break;
-
+
case 'r':
- raw=1;
- break;
-
+ raw=1;
+ break;
+
case 'f':
fps_only = 1;
outfile = NULL;
break;
-
+
default:
usage();
}
@@ -364,34 +375,34 @@
videobuf_time=th_granule_time(td,videobuf_granulepos);
videobuf_ready=1;
frames++;
- if(fps_only)
- ftime(&after);
+ if(fps_only)
+ ftime(&after);
}
-
+
}else
break;
}
if(fps_only && (videobuf_ready || fps_only==2)){
- long ms =
- after.time*1000.+after.millitm-
- (last.time*1000.+last.millitm);
-
- if(ms>500 || fps_only==1 ||
- (feof(infile) && !videobuf_ready)){
- float file_fps = (float)ti.fps_numerator/ti.fps_denominator;
- fps_only=2;
-
- ms = after.time*1000.+after.millitm-
- (start.time*1000.+start.millitm);
-
- fprintf(stderr,"\rframe:%d rate:%.2fx ",
- frames,
- frames*1000./(ms*file_fps));
- memcpy(&last,&after,sizeof(last));
+ long ms =
+ after.time*1000.+after.millitm-
+ (last.time*1000.+last.millitm);
+
+ if(ms>500 || fps_only==1 ||
+ (feof(infile) && !videobuf_ready)){
+ float file_fps = (float)ti.fps_numerator/ti.fps_denominator;
+ fps_only=2;
+
+ ms = after.time*1000.+after.millitm-
+ (start.time*1000.+start.millitm);
+
+ fprintf(stderr,"\rframe:%d rate:%.2fx ",
+ frames,
+ frames*1000./(ms*file_fps));
+ memcpy(&last,&after,sizeof(last));
}
}
-
+
if(!videobuf_ready && feof(infile))break;
if(!videobuf_ready ){
@@ -402,7 +413,7 @@
}
}
/* dumpvideo frame, and get new one */
- else
+ else
if(outfile)video_write();
videobuf_ready=0;
Modified: trunk/theora-exp/examples/encoder_example.c
===================================================================
--- trunk/theora-exp/examples/encoder_example.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/examples/encoder_example.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -16,13 +16,21 @@
********************************************************************/
-#define _GNU_SOURCE
#if !defined(_REENTRANT)
#define _REENTRANT
#endif
+#if !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+#if !defined(_LARGEFILE_SOURCE)
#define _LARGEFILE_SOURCE
+#endif
+#if !defined(_LARGEFILE64_SOURCE)
#define _LARGEFILE64_SOURCE
+#endif
+#if !defined(_FILE_OFFSET_BITS)
#define _FILE_OFFSET_BITS 64
+#endif
#include <stdio.h>
#include <unistd.h>
@@ -923,7 +931,7 @@
/* You'll go to Hell for using static variables */
static int state=-1;
static unsigned char *yuvframe[3];
- static th_ycbcr_buffer ycbcr;
+ static th_ycbcr_buffer ycbcr;
ogg_packet op;
int pic_sz;
int frame_c_w;
@@ -1061,9 +1069,9 @@
ogg_page og; /* one Ogg bitstream page. Vorbis packets are inside */
ogg_packet op; /* one raw packet of data for decode */
- th_enc_ctx *td;
- th_info ti;
- th_comment tc;
+ th_enc_ctx *td;
+ th_info ti;
+ th_comment tc;
vorbis_info vi; /* struct that stores all the static vorbis bitstream
settings */
Modified: trunk/theora-exp/examples/player_example.c
===================================================================
--- trunk/theora-exp/examples/player_example.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/examples/player_example.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -25,19 +25,25 @@
A simple 'demux and write back streams' would have been easier,
it's true. */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#if !defined(_REENTRANT)
+#define _REENTRANT
+#endif
+#if !defined(_GNU_SOURCE)
#define _GNU_SOURCE
+#endif
+#if !defined(_LARGEFILE_SOURCE)
#define _LARGEFILE_SOURCE
+#endif
+#if !defined(_LARGEFILE64_SOURCE)
#define _LARGEFILE64_SOURCE
+#endif
+#if !defined(_FILE_OFFSET_BITS)
#define _FILE_OFFSET_BITS 64
-
-#ifdef HAVE_CONFIG_H
-# include <config.h>
#endif
-#ifndef _REENTRANT
-# define _REENTRANT
-#endif
-
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -83,10 +89,10 @@
ogg_page og;
ogg_stream_state vo;
ogg_stream_state to;
-th_info ti;
-th_comment tc;
-th_setup_info *ts;
-th_dec_ctx *td;
+th_info ti;
+th_comment tc;
+th_setup_info *ts;
+th_dec_ctx *td;
vorbis_info vi;
vorbis_dsp_state vd;
vorbis_block vb;
@@ -583,7 +589,7 @@
dump_comments(&tc);
th_decode_ctl(td,TH_DECCTL_GET_PPLEVEL_MAX,&pp_level_max,
sizeof(pp_level_max));
- pp_level=pp_level_max;
+ pp_level=1;
th_decode_ctl(td,TH_DECCTL_SET_PPLEVEL,&pp_level,sizeof(pp_level));
pp_inc=0;
}else{
Modified: trunk/theora-exp/include/theora/codec.h
===================================================================
--- trunk/theora-exp/include/theora/codec.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/include/theora/codec.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -136,8 +136,7 @@
* as indicated by th_info#pixel_fmt.
* The width and height of the Y' plane must be multiples of 16.
* They may need to be cropped for display, using the rectangle specified by
- * th_info#pic_x, th_info#pic_y, th_info#pic_width, and
- * th_info#pic_height.
+ * th_info#pic_x, th_info#pic_y, th_info#pic_width, and th_info#pic_height.
* All samples are 8 bits.
* \note The term YUV often used to describe a colorspace is ambiguous.
* The exact parameters of the RGB to YUV conversion process aside, in many
@@ -451,8 +450,7 @@
/**Converts a granule position to an absolute frame number.
* The granule position is interpreted in the context of a given
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
- * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
- * handle.
+ * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx handle.
* \param _granpos The granule position to convert.
* \returns The absolute frame number corresponding to \a _granpos.
* \retval -1 The given granule position was invalid (i.e. negative).*/
@@ -460,8 +458,7 @@
/**Converts a granule position to an absolute time in seconds.
* The granule position is interpreted in the context of a given
* #th_enc_ctx or #th_dec_ctx handle (either will suffice).
- * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx
- * handle.
+ * \param _encdec A previously allocated #th_enc_ctx or #th_dec_ctx handle.
* \param _granpos The granule position to convert.
* \return The absolute time in seconds corresponding to \a _granpos.
* \retval -1 The given granule position was invalid (i.e. negative).*/
@@ -498,30 +495,27 @@
* \param _info The #th_info struct to initialize.*/
extern void th_info_init(th_info *_info);
/**Clears a #th_info structure.
- * This should be called on a #th_info structure after it is no longer
- * needed.
+ * This should be called on a #th_info structure after it is no longer needed.
* \param _info The #th_info struct to clear.*/
extern void th_info_clear(th_info *_info);
/**Initialize a #th_comment structure.
- * This should be called on a freshly allocated #th_comment structure
- * before attempting to use it.
+ * This should be called on a freshly allocated #th_comment structure before
+ * attempting to use it.
* \param _tc The #th_comment struct to initialize.*/
extern void th_comment_init(th_comment *_tc);
/**Add a comment to an initialized #th_comment structure.
- * \note Neither th_comment_add() nor th_comment_add_tag() support
- * comments containing null values, although the bitstream format does
- * support them.
- * To add such comments you will need to manipulate the #th_comment
- * structure directly.
+ * \note Neither th_comment_add() nor th_comment_add_tag() support comments
+ * containing null values, although the bitstream format does support them.
+ * To add such comments you will need to manipulate the #th_comment structure
+ * directly.
* \param _tc The #th_comment struct to add the comment to.
* \param _comment Must be a null-terminated UTF-8 string containing the
* comment in "TAG=the value" form.*/
extern void th_comment_add(th_comment *_tc, char *_comment);
/**Add a comment to an initialized #th_comment structure.
- * \note Neither th_comment_add() nor th_comment_add_tag() support
- * comments containing null values, although the bitstream format does
- * support them.
+ * \note Neither th_comment_add() nor th_comment_add_tag() support comments
+ * containing null values, although the bitstream format does support them.
* To add such comments you will need to manipulate the #th_comment
* structure directly.
* \param _tc The #th_comment struct to add the comment to.
@@ -537,8 +531,8 @@
* value, so an index is required to retrieve them all.
* The order in which these values appear is significant and
* should be preserved.
- * Use th_comment_query_count() to get the legal range for
- * the \a _count parameter.
+ * Use th_comment_query_count() to get the legal range for the
+ * \a _count parameter.
* \return A pointer to the queried tag's value.
* This points directly to data in the #th_comment structure.
* It should not be modified or freed by the application, and
@@ -547,8 +541,8 @@
extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
/**Look up the number of instances of a tag.
* Call this first when querying for a specific tag and then iterate over the
- * number of instances with separate calls to th_comment_query() to
- * retrieve all the values for that tag in order.
+ * number of instances with separate calls to th_comment_query() to retrieve
+ * all the values for that tag in order.
* \param _tc An initialized #th_comment structure.
* \param _tag The tag to look up.
* \return The number on instances of this particular tag.*/
Modified: trunk/theora-exp/include/theora/theoradec.h
===================================================================
--- trunk/theora-exp/include/theora/theoradec.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/include/theora/theoradec.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -71,16 +71,14 @@
/**Sets the striped decode callback function.
* If set, this function will be called as each piece of a frame is fully
* decoded in th_decode_packetin().
- * You can pass in a #th_stripe_callback with
- * th_stripe_callback#stripe_decoded set to <tt>NULL</tt> to disable the
- * callbacks at any point.
+ * You can pass in a #th_stripe_callback with th_stripe_callback#stripe_decoded
+ * set to <tt>NULL</tt> to disable the callbacks at any point.
* Enabling striped decode does not prevent you from calling
* th_decode_ycbcr_out() after the frame is fully decoded.
*
* \param[in] _buf #th_stripe_callback: The callback parameters.
* \retval TH_EFAULT \a _dec_ctx or \a _buf is <tt>NULL</tt>.
- * \retval TH_EINVAL \a _buf_sz is not
- * <tt>sizeof(th_stripe_callback)</tt>.*/
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(th_stripe_callback)</tt>.*/
#define TH_DECCTL_SET_STRIPE_CB (7)
/*@}*/
@@ -99,8 +97,8 @@
* format and the number of post-processing filters enabled, and may not even
* be constant for the entire frame.
* If a non-<tt>NULL</tt> \a _granpos pointer is passed to
- * th_decode_packetin(), the granule position for the frame will be stored
- * in it before the first callback is made.
+ * th_decode_packetin(), the granule position for the frame will be stored in
+ * it before the first callback is made.
* If an entire frame is dropped (a 0-byte packet), then no callbacks will be
* made at all for that frame.
* \param _ctx An application-provided context pointer.
@@ -160,8 +158,7 @@
* The basic steps are:
* - Parse the header packets by repeatedly calling th_decode_headerin().
* - Allocate a #th_dec_ctx handle with th_decode_alloc().
- * - Call th_setup_free() to free any memory used for codec setup
- * information.
+ * - Call th_setup_free() to free any memory used for codec setup information.
* - Perform any additional decoder configuration with th_decode_ctl().
* - For each video data packet:
* - Submit the packet to the decoder via th_decode_packetin().
@@ -273,8 +270,7 @@
* subsequent frames are decoded.
* \retval 0 Success
*/
-extern int th_decode_ycbcr_out(th_dec_ctx *_dec,
- th_ycbcr_buffer _ycbcr);
+extern int th_decode_ycbcr_out(th_dec_ctx *_dec,th_ycbcr_buffer _ycbcr);
/**Frees an allocated decoder instance.
* \param _dec A #th_dec_ctx handle.*/
extern void th_decode_free(th_dec_ctx *_dec);
Modified: trunk/theora-exp/include/theora/theoraenc.h
===================================================================
--- trunk/theora-exp/include/theora/theoraenc.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/include/theora/theoraenc.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -196,8 +196,8 @@
* This may be <tt>NULL</tt>, in which case the current VBR
* configuration is unchanged.
* The default is to use the QI setting passed in via the
- * #th_info struct when the encoder was initialized, with
- * a full range of admissible quantizers.
+ * #th_info struct when the encoder was initialized, with a
+ * full range of admissible quantizers.
* \retval OC_EFAULT \a _enc_ctx is <tt>NULL</tt>.
* \retval TH_EINVAL The configuration parameters do not meet one of their
* stated requirements, \a _buf is <tt>NULL</tt> and
@@ -253,8 +253,8 @@
*
* The functions are listed in the order they are used in a typical encode.
* The basic steps are:
- * - Fill in a #th_info structure with details on the format of the video
- * you wish to encode.
+ * - Fill in a #th_info structure with details on the format of the video you
+ * wish to encode.
* - Allocate a #th_enc_ctx handle with th_encode_alloc().
* - Perform any additional encoder configuration required with
* th_encode_ctl().
@@ -262,13 +262,12 @@
* packets.
* - For each uncompressed frame:
* - Submit the uncompressed frame via th_encode_ycbcr_in()
- * - Repeatedly call th_encode_packetout() to retrieve any video data
- * packets that are ready.
+ * - Repeatedly call th_encode_packetout() to retrieve any video data packets
+ * that are ready.
* - Call th_encode_free() to release all encoder memory.*/
/*@{*/
/**Allocates an encoder instance.
- * \param _info A #th_info struct filled with the desired encoding
- * parameters.
+ * \param _info A #th_info struct filled with the desired encoding parameters.
* \return The initialized #th_enc_ctx handle.
* \retval NULL If the encoding parameters were invalid.*/
extern th_enc_ctx *th_encode_alloc(const th_info *_info);
@@ -280,8 +279,7 @@
* for details.
* \param _buf The parameters for this control code.
* \param _buf_sz The size of the parameter buffer.*/
-extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,
- size_t _buf_sz);
+extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz);
/**Outputs the next header packet.
* This should be called repeatedly after encoder initialization until it
* returns 0 in order to get all of the header packets, in order, before
@@ -309,8 +307,7 @@
* \retval TH_EINVAL The buffer size does not match the frame size the encoder
* was initialized with, or encoding has already
* completed.*/
-extern int th_encode_ycbcr_in(th_enc_ctx *_enc,
- th_ycbcr_buffer _ycbcr);
+extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr);
/**Retrieves encoded video data packets.
* This should be called repeatedly after each frame is submitted to flush any
* encoded packets, until it returns 0.
@@ -334,8 +331,7 @@
* \retval 0 No packet was produced, and no more encoded video data
* remains.
* \retval TH_FAULT \a _enc or \a _op was <tt>NULL</tt>.*/
-extern int th_encode_packetout(th_enc_ctx *_enc,int _last,
- ogg_packet *_op);
+extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op);
/**Frees an allocated encoder instance.
* \param _enc A #th_enc_ctx handle.*/
extern void th_encode_free(th_enc_ctx *_enc);
Modified: trunk/theora-exp/lib/apiwrapper.c
===================================================================
--- trunk/theora-exp/lib/apiwrapper.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/apiwrapper.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -89,6 +89,7 @@
int theora_decode_init(theora_state *_td,theora_info *_ci){
th_api_wrapper *api;
th_api_wrapper *dapi;
+ theora_info *ci;
th_info info;
/*We don't need these two fields.*/
_td->internal_encode=NULL;
@@ -97,11 +98,10 @@
api=(th_api_wrapper *)_ci->codec_setup;
/*Make our own copy of the info struct, since its lifetime should be
independent of the one we were passed in.*/
- _td->i=(theora_info *)_ogg_malloc(sizeof(*_td->i));
- *_td->i=*_ci;
+ ci=(theora_info *)_ogg_malloc(sizeof(*_td->i));
+ *ci=*_ci;
/*Also make our own copy of the wrapper.*/
dapi=(th_api_wrapper *)_ogg_calloc(1,sizeof(*dapi));
- _td->i->codec_setup=dapi;
/*Convert the info struct now instead of saving the the one we decoded with
theora_decode_header(), since the user might have modified values (i.e.,
color space, aspect ratio, etc. can be specified from a higher level).
@@ -111,6 +111,14 @@
/*Don't bother to copy the setup info; th_decode_alloc() makes its own copy
of the stuff it needs.*/
dapi->decode=th_decode_alloc(&info,api->setup);
+ if(dapi->decode==NULL){
+ _ogg_free(ci);
+ _ogg_free(dapi);
+ return OC_EINVAL;
+ }
+ _td->i=ci;
+ _td->i->codec_setup=dapi;
+ return 0;
}
static void th_info2theora_info(theora_info *_ci,const th_info *_info){
Modified: trunk/theora-exp/lib/decinfo.c
===================================================================
--- trunk/theora-exp/lib/decinfo.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/decinfo.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -36,9 +36,7 @@
_info->version_subminor=(unsigned char)val;
if(_info->version_major>TH_VERSION_MAJOR||
_info->version_major==TH_VERSION_MAJOR&&
- (_info->version_minor>TH_VERSION_MINOR||
- _info->version_minor==TH_VERSION_MINOR&&
- _info->version_subminor>TH_VERSION_SUB)){
+ _info->version_minor>TH_VERSION_MINOR){
return TH_EVERSION;
}
/*Read the encoded frame description.*/
Modified: trunk/theora-exp/lib/decint.h
===================================================================
--- trunk/theora-exp/lib/decint.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/decint.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -20,7 +20,7 @@
struct th_setup_info{
/*The Huffman codes.*/
- oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
+ oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
/*The quantization parameters.*/
th_quant_info qinfo;
};
@@ -29,45 +29,45 @@
struct th_dec_ctx{
/*Shared encoder/decoder state.*/
- oc_theora_state state;
+ oc_theora_state state;
/*Whether or not packets are ready to be emitted.
This takes on negative values while there are remaining header packets to
be emitted, reaches 0 when the codec is ready for input, and goes to 1
when a frame has been processed and a data packet is ready.*/
- int packet_state;
+ int packet_state;
/*Buffer in which to assemble packets.*/
- oggpack_buffer opb;
+ oggpack_buffer opb;
/*Huffman decode trees.*/
- oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
+ oc_huff_node *huff_tables[TH_NHUFFMAN_TABLES];
/*The index of one past the last token in each plane for each coefficient.
The final entries are the total number of tokens for each coefficient.*/
- int ti0[3][64];
+ int ti0[3][64];
/*The index of one past the last extra bits entry in each plane for each
coefficient.
The final entries are the total number of extra bits entries for each
coefficient.*/
- int ebi0[3][64];
+ int ebi0[3][64];
/*The number of outstanding EOB runs at the start of each coefficient in each
plane.*/
- int eob_runs[3][64];
+ int eob_runs[3][64];
/*The DCT token lists.*/
- unsigned char **dct_tokens;
+ unsigned char **dct_tokens;
/*The extra bits associated with DCT tokens.*/
- ogg_uint16_t **extra_bits;
+ ogg_uint16_t **extra_bits;
/*The out-of-loop post-processing level.*/
- int pp_level;
+ int pp_level;
/*The DC scale used for out-of-loop deblocking.*/
- int pp_dc_scale[64];
+ int pp_dc_scale[64];
/*The sharpen modifier used for out-of-loop deringing.*/
- int pp_sharp_mod[64];
+ int pp_sharp_mod[64];
/*The DC quantization index of each block.*/
- unsigned char *dc_qis;
+ unsigned char *dc_qis;
/*The variance of each block.*/
- int *variances;
+ int *variances;
/*The storage for the post-processed frame buffer.*/
- unsigned char *pp_frame_data;
+ unsigned char *pp_frame_data;
/*Whether or not the post-processsed frame buffer has space for chroma.*/
- int pp_frame_has_chroma;
+ int pp_frame_has_chroma;
/*The buffer used for the post-processed frame.*/
th_ycbcr_buffer pp_frame_buf;
/*The striped decode callback function.*/
Modified: trunk/theora-exp/lib/decode.c
===================================================================
--- trunk/theora-exp/lib/decode.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/decode.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -213,7 +213,8 @@
int ret;
ret=oc_state_init(&_dec->state,_info);
if(ret<0)return ret;
- oc_huff_trees_copy(_dec->huff_tables,_setup->huff_tables);
+ oc_huff_trees_copy(_dec->huff_tables,
+ (const oc_huff_node *const *)_setup->huff_tables);
for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){
_dec->state.dequant_tables[qti][pli]=
_dec->state.dequant_table_data[qti][pli];
@@ -580,13 +581,13 @@
static void oc_dec_mv_unpack_and_frag_modes_fill(oc_dec_ctx *_dec){
oc_set_chroma_mvs_func set_chroma_mvs;
oc_mv_comp_unpack_func mv_comp_unpack;
+ oc_mv last_mv[2];
+ oc_mv cbmvs[4];
oc_mb *mb;
oc_mb *mb_end;
const int *map_idxs;
long val;
int map_nidxs;
- char last_mv[2][2];
- char cbmvs[4][2];
set_chroma_mvs=OC_SET_CHROMA_MVS_TABLE[_dec->state.info.pixel_fmt];
theora_read1(&_dec->opb,&val);
mv_comp_unpack=val?oc_clc_mv_comp_unpack:oc_vlc_mv_comp_unpack;
@@ -597,13 +598,14 @@
mb_end=mb+_dec->state.nmbs;
for(;mb<mb_end;mb++)if(mb->mode!=OC_MODE_INVALID){
oc_fragment *frag;
- char mbmv[2];
+ oc_mv mbmv;
int coded[13];
int codedi;
int ncoded;
int mapi;
int mapii;
int fragi;
+ int mode;
/*Search for at least one coded fragment.*/
ncoded=mapii=0;
do{
@@ -613,17 +615,18 @@
}
while(++mapii<map_nidxs);
if(ncoded<=0)continue;
- switch(mb->mode){
+ mode=mb->mode;
+ switch(mode){
case OC_MODE_INTER_MV_FOUR:{
- char lbmvs[4][2];
- int bi;
+ oc_mv lbmvs[4];
+ int bi;
/*Mark the tail of the list, so we don't accidentally go past it.*/
coded[ncoded]=-1;
for(bi=codedi=0;bi<4;bi++){
if(coded[codedi]==bi){
codedi++;
frag=_dec->state.frags+mb->map[0][bi];
- frag->mbmode=mb->mode;
+ frag->mbmode=mode;
frag->mv[0]=lbmvs[bi][0]=(char)(*mv_comp_unpack)(&_dec->opb);
frag->mv[1]=lbmvs[bi][1]=(char)(*mv_comp_unpack)(&_dec->opb);
}
@@ -636,12 +639,12 @@
last_mv[0][1]=lbmvs[coded[codedi-1]][1];
}
if(codedi<ncoded){
- (*set_chroma_mvs)(cbmvs,lbmvs);
+ (*set_chroma_mvs)(cbmvs,(const oc_mv *)lbmvs);
for(;codedi<ncoded;codedi++){
mapi=coded[codedi];
bi=mapi&3;
frag=_dec->state.frags+mb->map[mapi>>2][bi];
- frag->mbmode=mb->mode;
+ frag->mbmode=mode;
frag->mv[0]=cbmvs[bi][0];
frag->mv[1]=cbmvs[bi][1];
}
@@ -673,12 +676,12 @@
}
/*4MV mode fills in the fragments itself.
For all other modes we can use this common code.*/
- if(mb->mode!=OC_MODE_INTER_MV_FOUR){
+ if(mode!=OC_MODE_INTER_MV_FOUR){
for(codedi=0;codedi<ncoded;codedi++){
mapi=coded[codedi];
fragi=mb->map[mapi>>2][mapi&3];
frag=_dec->state.frags+fragi;
- frag->mbmode=mb->mode;
+ frag->mbmode=mode;
frag->mv[0]=mbmv[0];
frag->mv[1]=mbmv[1];
}
@@ -1588,9 +1591,8 @@
}
}
-static void oc_dec_deblock_frag_rows(oc_dec_ctx *_dec,
- th_img_plane *_dst,th_img_plane *_src,int _pli,int _fragy0,
- int _fragy_end){
+static void oc_dec_deblock_frag_rows(oc_dec_ctx *_dec,th_img_plane *_dst,
+ th_img_plane *_src,int _pli,int _fragy0,int _fragy_end){
oc_fragment_plane *fplane;
int *variance;
unsigned char *dc_qi;
@@ -1789,7 +1791,7 @@
static void oc_dec_dering_frag_rows(oc_dec_ctx *_dec,th_img_plane *_img,
int _pli,int _fragy0,int _fragy_end){
- th_img_plane *iplane;
+ th_img_plane *iplane;
oc_fragment_plane *fplane;
oc_fragment *frag;
int *variance;
@@ -1848,8 +1850,7 @@
-th_dec_ctx *th_decode_alloc(const th_info *_info,
- const th_setup_info *_setup){
+th_dec_ctx *th_decode_alloc(const th_info *_info,const th_setup_info *_setup){
oc_dec_ctx *dec;
if(_info==NULL||_setup==NULL)return NULL;
dec=_ogg_malloc(sizeof(*dec));
@@ -1921,7 +1922,7 @@
Only proceed if we have a non-empty packet.*/
if(_op->bytes!=0){
oc_dec_pipeline_state pipe;
- th_ycbcr_buffer stripe_buf;
+ th_ycbcr_buffer stripe_buf;
int stripe_fragy;
int refi;
int pli;
@@ -1936,12 +1937,12 @@
(_dec->state.ref_frame_idx[OC_FRAME_GOLD]<0||
_dec->state.ref_frame_idx[OC_FRAME_PREV]<0)){
th_info *info;
- size_t yplane_sz;
- size_t cplane_sz;
- int yhstride;
- int yvstride;
- int chstride;
- int cvstride;
+ size_t yplane_sz;
+ size_t cplane_sz;
+ int yhstride;
+ int yvstride;
+ int chstride;
+ int cvstride;
/*We're decoding an INTER frame, but have no initialized reference
buffers (i.e., decoding did not start on a key frame).
We initialize them to a solid gray here.*/
Modified: trunk/theora-exp/lib/dequant.c
===================================================================
--- trunk/theora-exp/lib/dequant.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/dequant.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -6,21 +6,20 @@
-int oc_quant_params_unpack(oggpack_buffer *_opb,
- th_quant_info *_qinfo){
+int oc_quant_params_unpack(oggpack_buffer *_opb,th_quant_info *_qinfo){
th_quant_base *base_mats;
- long val;
- int nbase_mats;
- int sizes[64];
- int indices[64];
- int nbits;
- int bmi;
- int ci;
- int qti;
- int pli;
- int qri;
- int qi;
- int i;
+ long val;
+ int nbase_mats;
+ int sizes[64];
+ int indices[64];
+ int nbits;
+ int bmi;
+ int ci;
+ int qti;
+ int pli;
+ int qri;
+ int qi;
+ int i;
theora_read(_opb,3,&val);
nbits=(int)val;
for(qi=0;qi<64;qi++){
@@ -52,7 +51,7 @@
for(i=0;i<6;i++){
th_quant_ranges *qranges;
th_quant_base *qrbms;
- int *qrsizes;
+ int *qrsizes;
qti=i/3;
pli=i%3;
qranges=_qinfo->qi_ranges[qti]+pli;
@@ -98,8 +97,8 @@
qranges->nranges=qri;
qranges->sizes=qrsizes=(int *)_ogg_malloc(qri*sizeof(qrsizes[0]));
memcpy(qrsizes,sizes,qri*sizeof(qrsizes[0]));
- qranges->base_matrices=qrbms=(th_quant_base *)_ogg_malloc(
- (qri+1)*sizeof(qrbms[0]));
+ qrbms=(th_quant_base *)_ogg_malloc((qri+1)*sizeof(qrbms[0]));
+ qranges->base_matrices=(const th_quant_base *)qrbms;
do{
bmi=indices[qri];
/*Note: The caller is responsible for cleaning up any partially
Modified: trunk/theora-exp/lib/dequant.h
===================================================================
--- trunk/theora-exp/lib/dequant.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/dequant.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -2,8 +2,7 @@
# define _dequant_H (1)
# include "quant.h"
-int oc_quant_params_unpack(oggpack_buffer *_opb,
- th_quant_info *_qinfo);
+int oc_quant_params_unpack(oggpack_buffer *_opb,th_quant_info *_qinfo);
void oc_quant_params_clear(th_quant_info *_qinfo);
#endif
Modified: trunk/theora-exp/lib/encinfo.c
===================================================================
--- trunk/theora-exp/lib/encinfo.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/encinfo.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -1,6 +1,8 @@
#include <stdlib.h>
#include <string.h>
-#include "encint.h"
+#include "internal.h"
+#include "enquant.h"
+#include "huffenc.h"
@@ -15,81 +17,81 @@
-int th_encode_flushheader(th_enc_ctx *_enc,th_comment *_tc,
- ogg_packet *_op){
- if(_enc==NULL||_op==NULL)return TH_EFAULT;
- switch(_enc->packet_state){
+int oc_state_flushheader(oc_theora_state *_state,int *_packet_state,
+ oggpack_buffer *_opb,const th_quant_info *_qinfo,
+ const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS],
+ const char *_vendor,th_comment *_tc,ogg_packet *_op){
+ if(_state==NULL||_op==NULL)return TH_EFAULT;
+ switch(*_packet_state){
/*Codec info header.*/
case OC_PACKET_INFO_HDR:{
- oggpackB_reset(&_enc->opb);
+ oggpackB_reset(_opb);
/*Mark this packet as the info header.*/
- oggpackB_write(&_enc->opb,0x80,8);
+ oggpackB_write(_opb,0x80,8);
/*Write the codec string.*/
- oc_pack_octets(&_enc->opb,"theora",6);
+ oc_pack_octets(_opb,"theora",6);
/*Write the codec bitstream version.*/
- oggpackB_write(&_enc->opb,TH_VERSION_MAJOR,8);
- oggpackB_write(&_enc->opb,TH_VERSION_MINOR,8);
- oggpackB_write(&_enc->opb,TH_VERSION_SUB,8);
+ oggpackB_write(_opb,TH_VERSION_MAJOR,8);
+ oggpackB_write(_opb,TH_VERSION_MINOR,8);
+ oggpackB_write(_opb,TH_VERSION_SUB,8);
/*Describe the encoded frame.*/
- oggpackB_write(&_enc->opb,_enc->state.info.frame_width>>4,16);
- oggpackB_write(&_enc->opb,_enc->state.info.frame_height>>4,16);
- oggpackB_write(&_enc->opb,_enc->state.info.pic_width,24);
- oggpackB_write(&_enc->opb,_enc->state.info.pic_height,24);
- oggpackB_write(&_enc->opb,_enc->state.info.pic_x,8);
- oggpackB_write(&_enc->opb,_enc->state.info.frame_height-
- _enc->state.info.pic_height-_enc->state.info.pic_y,8);
- oggpackB_write(&_enc->opb,_enc->state.info.fps_numerator,32);
- oggpackB_write(&_enc->opb,_enc->state.info.fps_denominator,32);
- oggpackB_write(&_enc->opb,_enc->state.info.aspect_numerator,24);
- oggpackB_write(&_enc->opb,_enc->state.info.aspect_denominator,24);
- oggpackB_write(&_enc->opb,_enc->state.info.colorspace,8);
- oggpackB_write(&_enc->opb,_enc->state.info.target_bitrate,24);
- oggpackB_write(&_enc->opb,_enc->state.info.quality,6);
- oggpackB_write(&_enc->opb,_enc->state.info.keyframe_granule_shift,5);
- oggpackB_write(&_enc->opb,_enc->state.info.pixel_fmt,2);
+ oggpackB_write(_opb,_state->info.frame_width>>4,16);
+ oggpackB_write(_opb,_state->info.frame_height>>4,16);
+ oggpackB_write(_opb,_state->info.pic_width,24);
+ oggpackB_write(_opb,_state->info.pic_height,24);
+ oggpackB_write(_opb,_state->info.pic_x,8);
+ oggpackB_write(_opb,_state->info.frame_height-
+ _state->info.pic_height-_state->info.pic_y,8);
+ oggpackB_write(_opb,_state->info.fps_numerator,32);
+ oggpackB_write(_opb,_state->info.fps_denominator,32);
+ oggpackB_write(_opb,_state->info.aspect_numerator,24);
+ oggpackB_write(_opb,_state->info.aspect_denominator,24);
+ oggpackB_write(_opb,_state->info.colorspace,8);
+ oggpackB_write(_opb,_state->info.target_bitrate,24);
+ oggpackB_write(_opb,_state->info.quality,6);
+ oggpackB_write(_opb,_state->info.keyframe_granule_shift,5);
+ oggpackB_write(_opb,_state->info.pixel_fmt,2);
/*Spare configuration bits.*/
- oggpackB_write(&_enc->opb,0,3);
+ oggpackB_write(_opb,0,3);
_op->b_o_s=1;
}break;
/*Comment header.*/
case OC_PACKET_COMMENT_HDR:{
- const char *vendor;
- int vendor_len;
- int i;
+ int vendor_len;
+ int i;
if(_tc==NULL)return TH_EFAULT;
- vendor=th_version_string();
- vendor_len=strlen(vendor);
- oggpackB_reset(&_enc->opb);
+ vendor_len=strlen(_vendor);
+ oggpackB_reset(_opb);
/*Mark this packet as the comment header.*/
- oggpackB_write(&_enc->opb,0x81,8);
+ oggpackB_write(_opb,0x81,8);
/*Write the codec string.*/
- oc_pack_octets(&_enc->opb, "theora", 6);
+ oc_pack_octets(_opb,"theora",6);
/*Write the vendor string.*/
- oggpack_write(&_enc->opb,vendor_len,32);
- oc_pack_octets(&_enc->opb,vendor,vendor_len);
- oggpack_write(&_enc->opb,_tc->comments,32);
+ oggpack_write(_opb,vendor_len,32);
+ oc_pack_octets(_opb,_vendor,vendor_len);
+ oggpack_write(_opb,_tc->comments,32);
for(i=0;i<_tc->comments;i++){
if(_tc->user_comments[i]!=NULL){
- oggpack_write(&_enc->opb,_tc->comment_lengths[i],32);
- oc_pack_octets(&_enc->opb,_tc->user_comments[i],
+ oggpack_write(_opb,_tc->comment_lengths[i],32);
+ oc_pack_octets(_opb,_tc->user_comments[i],
_tc->comment_lengths[i]);
}
- else oggpack_write(&_enc->opb,0,32);
+ else oggpack_write(_opb,0,32);
}
_op->b_o_s=0;
}break;
/*Codec setup header.*/
case OC_PACKET_SETUP_HDR:{
int ret;
- oggpackB_reset(&_enc->opb);
+ oggpackB_reset(_opb);
/*Mark this packet as the setup header.*/
- oggpackB_write(&_enc->opb,0x82,8);
+ oggpackB_write(_opb,0x82,8);
/*Write the codec string.*/
- oc_pack_octets(&_enc->opb,"theora",6);
+ oc_pack_octets(_opb,"theora",6);
/*Write the quantizer tables.*/
- oc_quant_params_pack(&_enc->opb,&_enc->qinfo);
+ oc_quant_params_pack(_opb,_qinfo);
/*Write the huffman codes.*/
- ret=oc_huff_codes_pack(&_enc->opb,_enc->huff_codes);
+ ret=oc_huff_codes_pack(_opb,_codes);
/*This should never happen, because we validate the tables when they
are set.
If you see, it's a good chance memory is being corrupted.*/
@@ -105,11 +107,11 @@
Vorbis is little better: it hands back buffers that it will free the next
time the headers are requested, or when the encoder is cleared.
Hopefully libogg2 will make this much cleaner.*/
- _op->packet=oggpackB_get_buffer(&_enc->opb);
- _op->bytes=oggpackB_bytes(&_enc->opb);
+ _op->packet=oggpackB_get_buffer(_opb);
+ _op->bytes=oggpackB_bytes(_opb);
_op->e_o_s=0;
_op->granulepos=0;
/*Is this smart? Vorbis does not even set this field.*/
_op->packetno=0;
- return ++_enc->packet_state+3;
+ return ++(*_packet_state)+3;
}
Modified: trunk/theora-exp/lib/encint.h
===================================================================
--- trunk/theora-exp/lib/encint.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/encint.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -4,13 +4,14 @@
# include "theora/theoraenc.h"
# include "internal.h"
+typedef th_huff_code th_huff_table[TH_NDCT_TOKENS];
typedef struct oc_enc_pipe_stage oc_enc_pipe_stage;
typedef struct oc_fragment_enc_info oc_fragment_enc_info;
typedef struct oc_mb_enc_info oc_mb_enc_info;
typedef struct oc_mode_scheme_chooser oc_mode_scheme_chooser;
typedef struct oc_enc_vbr_ctx oc_enc_vbr_ctx;
typedef struct oc_mcenc_ctx oc_mcenc_ctx;
-typedef struct th_enc_ctx oc_enc_ctx;
+typedef struct th_enc_ctx oc_enc_ctx;
# include "fdct.h"
# include "huffenc.h"
@@ -129,19 +130,19 @@
alphabet used by each scheme.
The first entry points to the dynamic scheme0_ranks, while the remaining
7 point to the constant entries stored in OC_MODE_SCHEMES.*/
- const int *mode_ranks[8];
+ const int *mode_ranks[8];
/*The ranks for each mode when coded with scheme 0.
These are optimized so that the more frequent modes have lower ranks.*/
- int scheme0_ranks[OC_NMODES];
+ int scheme0_ranks[OC_NMODES];
/*The list of modes, sorted in descending order of frequency, that
corresponds to the ranks above.*/
- int scheme0_list[OC_NMODES];
+ int scheme0_list[OC_NMODES];
/*The number of times each mode has been chosen so far.*/
- int mode_counts[OC_NMODES];
+ int mode_counts[OC_NMODES];
/*The list of mode coding schemes, sorted in ascending order of bit cost.*/
- int scheme_list[8];
+ int scheme_list[8];
/*The number of bits used by each mode coding scheme.*/
- int scheme_bits[8];
+ int scheme_bits[8];
};
@@ -211,9 +212,9 @@
/*The bounding value array used for the loop filter.*/
int bounding_values[512];
/*The huffman tables in use.*/
- th_huff_code huff_codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
+ th_huff_code huff_codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
/*The quantization parameters in use.*/
- th_quant_info qinfo;
+ th_quant_info qinfo;
/*Pointers to the quantization tables in use.*/
oc_quant_table *enquant_tables[2][3];
/*Storage for the actual quantization tables.*/
@@ -235,7 +236,6 @@
extern const int OC_MODE_SCHEMES[7][OC_NMODES];
extern const int OC_DCT_VAL_CAT_SIZES[6];
extern const int OC_DCT_VAL_CAT_SHIFTS[6];
-extern const int OC_MODE_HAS_MV[OC_NMODES];
extern const th_huff_code OC_MV_CODES[2][63];
/*The number of fractional bits in bitrate statistics.*/
@@ -264,6 +264,11 @@
const unsigned char *_ref0,const unsigned char *_ref1,int _ref_stride,
ogg_int64_t _mask);
+int oc_state_flushheader(oc_theora_state *_state,int *_packet_state,
+ oggpack_buffer *_opb,const th_quant_info *_qinfo,
+ const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS],
+ const char *_vendor,th_comment *_tc,ogg_packet *_op);
+
void oc_mode_scheme_chooser_init(oc_mode_scheme_chooser *_chooser);
void oc_mode_scheme_chooser_reset(oc_mode_scheme_chooser *_chooser);
int oc_mode_scheme_chooser_cost(oc_mode_scheme_chooser *_chooser,int _mode);
Modified: trunk/theora-exp/lib/encode.c
===================================================================
--- trunk/theora-exp/lib/encode.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/encode.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -37,10 +37,6 @@
of the different DCT value category tokens.*/
const int OC_DCT_VAL_CAT_SHIFTS[6]={1,2,3,4,5,9};
-/*Whether or not each mode has a motion vector associated with it.
- Otherwise, the mode is assumed to use the 0,0 vector.*/
-const int OC_MODE_HAS_MV[OC_NMODES]={0,0,1,1,1,1,0,1};
-
/*The Huffman codes used for motion vectors.*/
const th_huff_code OC_MV_CODES[2][63]={
/*Scheme 1: VLC code.*/
@@ -598,11 +594,11 @@
_token_counts_y: Returns the token counts for the Y' plane.
_token_counts_c: Returns the token counts for the Cb and Cr planes.*/
static void oc_enc_count_tokens(oc_enc_ctx *_enc,int _zzi_start,int _zzi_end,
- int _token_counts_y[32],int _token_counts_c[32]){
+ int _token_counts_y[TH_NDCT_TOKENS],int _token_counts_c[TH_NDCT_TOKENS]){
int zzi;
int ti;
- memset(_token_counts_y,0,sizeof(_token_counts_y[0])*32);
- memset(_token_counts_c,0,sizeof(_token_counts_c[0])*32);
+ memset(_token_counts_y,0,sizeof(_token_counts_y[0])*TH_NDCT_TOKENS);
+ memset(_token_counts_c,0,sizeof(_token_counts_c[0])*TH_NDCT_TOKENS);
for(zzi=_zzi_start;zzi<_zzi_end;zzi++){
for(ti=_enc->dct_token_offs[0][zzi];ti<_enc->dct_token_offs[1][zzi];ti++){
_token_counts_y[_enc->dct_tokens[zzi][ti]]++;
@@ -617,14 +613,14 @@
/*Computes the number of bits used for each of the potential Huffman codes for
the given list of token counts.
The bits are added to whatever the current bit counts are.*/
-static void oc_enc_count_bits(oc_enc_ctx *_enc,int _hgi,const int _token_counts[32],
- int _bit_counts[16]){
+static void oc_enc_count_bits(oc_enc_ctx *_enc,int _hgi,
+ const int _token_counts[TH_NDCT_TOKENS],int _bit_counts[16]){
int huffi;
int huff_base;
int token;
huff_base=_hgi<<4;
for(huffi=huff_base;huffi<huff_base+16;huffi++){
- for(token=0;token<32;token++){
+ for(token=0;token<TH_NDCT_TOKENS;token++){
_bit_counts[huffi-huff_base]+=
_token_counts[token]*_enc->huff_codes[huffi][token].nbits;
}
@@ -655,8 +651,8 @@
ebi=_enc->extra_bits_offs[zzi];
for(pli=0;pli<3;pli++){
const th_huff_code *huff_codes;
- int token;
- int ti_end;
+ int token;
+ int ti_end;
/*Step 2: Write the tokens using these tables.*/
huff_codes=_enc->huff_codes[_huff_idxs[pli]];
/*Note: dct_token_offs[3] is really the ndct_tokens table.
@@ -677,12 +673,12 @@
}
static void oc_enc_residual_tokens_pack(oc_enc_ctx *_enc){
- static const int OC_HUFF_LIST_MIN[5]={0,1,6,15,28};
- static const int OC_HUFF_LIST_MAX[5]={1,6,15,28,64};
+ static const int OC_HUFF_LIST_MIN[6]={0,1,6,15,28,64};
+ static const int *OC_HUFF_LIST_MAX=OC_HUFF_LIST_MIN+1;
int bits_y[16];
int bits_c[16];
- int token_counts_y[32];
- int token_counts_c[32];
+ int token_counts_y[TH_NDCT_TOKENS];
+ int token_counts_c[TH_NDCT_TOKENS];
int huff_idxs[5][3];
int huffi_y;
int huffi_c;
@@ -729,10 +725,10 @@
static void oc_enc_mb_modes_pack(oc_enc_ctx *_enc){
const th_huff_code *codes;
- const int *mode_ranks;
- int *coded_mbi;
- int *coded_mbi_end;
- int scheme;
+ const int *mode_ranks;
+ int *coded_mbi;
+ int *coded_mbi_end;
+ int scheme;
scheme=_enc->mode_scheme_chooser.scheme_list[0];
oggpackB_write(&_enc->opb,scheme,3);
if(scheme==0){
@@ -753,7 +749,7 @@
coded_mbi_end=coded_mbi+_enc->state.ncoded_mbis;
for(;coded_mbi<coded_mbi_end;coded_mbi++){
const th_huff_code *code;
- oc_mb *mb;
+ oc_mb *mb;
mb=_enc->state.mbs+*coded_mbi;
code=codes+mode_ranks[mb->mode];
oggpackB_write(&_enc->opb,code->pattern,code->nbits);
@@ -1114,6 +1110,8 @@
oc_free_2d(_enc->dct_tokens);
_ogg_free(_enc->mbinfo);
_ogg_free(_enc->frinfo);
+ oggpackB_writeclear(&_enc->opb_coded_flags);
+ oggpackB_writeclear(&_enc->opb);
_ogg_free(_enc->block_coded_flags);
oc_state_clear(&_enc->state);
}
@@ -1342,17 +1340,14 @@
-typedef th_huff_code theora_huff_table[TH_NDCT_TOKENS];
-
-int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,
- size_t _buf_sz){
+int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz){
switch(_req){
case TH_ENCCTL_SET_HUFFMAN_CODES:{
if(_buf==NULL&&_buf_sz!=0||_buf!=NULL&&
_buf_sz!=sizeof(th_huff_code)*TH_NHUFFMAN_TABLES*TH_NDCT_TOKENS){
return TH_EINVAL;
}
- return oc_enc_set_huffman_codes(_enc,(theora_huff_table *)_buf);
+ return oc_enc_set_huffman_codes(_enc,(const th_huff_table *)_buf);
}break;
case TH_ENCCTL_SET_QUANT_PARAMS:{
if(_buf==NULL&&_buf_sz!=0||
@@ -1437,14 +1432,20 @@
}
}
+int th_encode_flushheader(th_enc_ctx *_enc,th_comment *_tc,ogg_packet *_op){
+ return oc_state_flushheader(&_enc->state,&_enc->packet_state,&_enc->opb,
+ &_enc->qinfo,(const th_huff_table *)_enc->huff_codes,th_version_string(),
+ _tc,_op);
+}
+
int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _img){
th_ycbcr_buffer img;
- int y_avail[3];
- int cwidth;
- int cheight;
- int ret;
- int rfi;
- int pli;
+ int y_avail[3];
+ int cwidth;
+ int cheight;
+ int ret;
+ int rfi;
+ int pli;
/*Step 1: validate parameters.*/
if(_enc==NULL||_img==NULL)return TH_EFAULT;
if(_enc->packet_state==OC_PACKET_DONE)return TH_EINVAL;
Modified: trunk/theora-exp/lib/encvbr.c
===================================================================
--- trunk/theora-exp/lib/encvbr.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/encvbr.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -840,7 +840,7 @@
oc_fragment *frag;
oc_mb *mb;
oc_mb_enc_info *mbinfo;
- char last_mv[2][2];
+ oc_mv last_mv[2];
int *uncoded_fragi;
int *uncoded_fragi_end;
int best_qii;
@@ -868,8 +868,8 @@
mb=_enc->state.mbs+mbi;
if(mb->mode!=OC_MODE_INVALID){
oc_fragment_enc_info *efrag;
- char bmvs[2][4][2];
- char mbmv[2];
+ oc_mv bmvs[2][4];
+ oc_mv mbmv;
int err[OC_NMODES][12];
int bits[OC_NMODES];
int coded[13];
@@ -885,6 +885,7 @@
int mbgmvbitsa;
int mb4mvbitsa;
int mb4mvbitsb;
+ int mode;
int fti;
int qti;
int bi;
@@ -978,7 +979,7 @@
/*Otherwise, add this to the coded MB list.*/
_enc->state.coded_mbis[_enc->state.ncoded_mbis++]=mbi;
/*Compute the chroma MVs for the 4MV mode.*/
- (*set_chroma_mvs)(bmvs[1],bmvs[0]);
+ (*set_chroma_mvs)(bmvs[1],(const oc_mv *)bmvs[0]);
/*Do a MV search against the golden frame.*/
oc_mcenc_search_1mv(_enc->mcenc,mb-_enc->state.mbs,OC_FRAME_GOLD);
/*We are now ready to do mode decision for this macro block.
@@ -1097,14 +1098,14 @@
bits[OC_MODE_INTER_MV_FOUR]+=OC_MINI(mvbitsa+mb4mvbitsa,
mvbitsb+mb4mvbitsb)-OC_MINI(mvbitsa,mvbitsb);
/*Finally, pick the mode with the cheapest estimated bit cost.*/
- mb->mode=0;
- for(modei=1;modei<OC_NMODES;modei++)if(bits[modei]<bits[mb->mode]){
+ mode=0;
+ for(modei=1;modei<OC_NMODES;modei++)if(bits[modei]<bits[mode]){
/*Do not select 4MV mode when not all the luma blocks are coded when
we're in VP3 compatibility mode.*/
if(_enc->vp3_compatible&&modei==OC_MODE_INTER_MV_FOUR&&ncoded_luma<4){
continue;
}
- mb->mode=modei;
+ mode=modei;
}
#if defined(OC_BITRATE_STATS)
/*Remember the error for the mode we selected in each fragment.*/
@@ -1112,7 +1113,7 @@
mapi=coded[codedi];
fragi=mb->map[mapi>>2][mapi&3];
efrag=_enc->frinfo+fragi;
- efrag->eerror=err[mb->mode][mapi];
+ efrag->eerror=err[mode][mapi];
}
#endif
/*Go back and store the selected qi index corresponding to the selected
@@ -1123,13 +1124,14 @@
frag=_enc->state.frags+fragi;
efrag=_enc->frinfo+fragi;
efrag->qii=(unsigned char)
- frag_qii[codedi][OC_INTER_FRAME][mb->mode!=0];
+ frag_qii[codedi][OC_INTER_FRAME][mode!=0];
frag->qi=_enc->qis[OC_INTER_FRAME][efrag->qii];
}
- inter_bits+=bits[mb->mode];
+ inter_bits+=bits[mode];
intra_bits+=mbintrabits+(1<<OC_BIT_SCALE-1)>>OC_BIT_SCALE;
- oc_mode_scheme_chooser_update(&_enc->mode_scheme_chooser,mb->mode);
- switch(mb->mode){
+ oc_mode_scheme_chooser_update(&_enc->mode_scheme_chooser,mode);
+ mb->mode=mode;
+ switch(mode){
case OC_MODE_INTER_MV:{
mvbitsa+=mbpmvbitsa;
mvbitsb+=12;
@@ -1168,42 +1170,31 @@
mbmv[0]=mbinfo->mvs[0][OC_FRAME_GOLD][0];
mbmv[1]=mbinfo->mvs[0][OC_FRAME_GOLD][1];
}break;
+ default:mbmv[0]=mbmv[1]=0;break;
}
- if(OC_MODE_HAS_MV[mb->mode]){
- /*Special case 4MV mode.
- MVs are stored in bmvs.*/
- if(mb->mode==OC_MODE_INTER_MV_FOUR){
- for(codedi=0;codedi<ncoded;codedi++){
- mapi=coded[codedi];
- pli=mapi>>2;
- bi=mapi&3;
- fragi=mb->map[pli][bi];
- frag=_enc->state.frags+fragi;
- frag->mbmode=mb->mode;
- frag->mv[0]=bmvs[!!pli][bi][0];
- frag->mv[1]=bmvs[!!pli][bi][1];
- }
+ /*Special case 4MV mode.
+ MVs are stored in bmvs.*/
+ if(mode==OC_MODE_INTER_MV_FOUR){
+ for(codedi=0;codedi<ncoded;codedi++){
+ mapi=coded[codedi];
+ pli=mapi>>2;
+ bi=mapi&3;
+ fragi=mb->map[pli][bi];
+ frag=_enc->state.frags+fragi;
+ frag->mbmode=mode;
+ frag->mv[0]=bmvs[!!pli][bi][0];
+ frag->mv[1]=bmvs[!!pli][bi][1];
}
- /*For every other mode with a MV, it is stored in mbmv.*/
- else{
- for(codedi=0;codedi<ncoded;codedi++){
- mapi=coded[codedi];
- fragi=mb->map[mapi>>2][mapi&3];
- frag=_enc->state.frags+fragi;
- frag->mbmode=mb->mode;
- frag->mv[0]=mbmv[0];
- frag->mv[1]=mbmv[1];
- }
- }
}
- /*For modes with no MV, ensure 0,0 is stored in each fragment.*/
+ /*For every other mode, the MV is stored in mbmv.*/
else{
for(codedi=0;codedi<ncoded;codedi++){
mapi=coded[codedi];
fragi=mb->map[mapi>>2][mapi&3];
frag=_enc->state.frags+fragi;
- frag->mbmode=mb->mode;
- frag->mv[0]=frag->mv[1]=0;
+ frag->mbmode=mode;
+ frag->mv[0]=mbmv[0];
+ frag->mv[1]=mbmv[1];
}
}
}
Modified: trunk/theora-exp/lib/encvbr.h
===================================================================
--- trunk/theora-exp/lib/encvbr.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/encvbr.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -12,7 +12,7 @@
/*Context information for the VBR encoder.*/
struct oc_enc_vbr_ctx{
/*Configuration information.*/
- th_vbr_cfg cfg;
+ th_vbr_cfg cfg;
/*The main VBR encoder's pipe stage.*/
oc_enc_pipe_stage pipe;
/*The scale factor for the current quality setting.*/
Modified: trunk/theora-exp/lib/enquant.c
===================================================================
--- trunk/theora-exp/lib/enquant.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/enquant.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -729,22 +729,21 @@
};
-void oc_quant_params_pack(oggpack_buffer *_opb,
- const th_quant_info *_qinfo){
+void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo){
const th_quant_ranges *qranges;
const th_quant_base *base_mats[2*3*64];
- int indices[2][3][64];
- int nbase_mats;
- int nbits;
- int ci;
- int qi;
- int qri;
- int qti;
- int pli;
- int qtj;
- int plj;
- int bmi;
- int i;
+ int indices[2][3][64];
+ int nbase_mats;
+ int nbits;
+ int ci;
+ int qi;
+ int qri;
+ int qti;
+ int pli;
+ int qtj;
+ int plj;
+ int bmi;
+ int i;
/*323 bits for the defaults.*/
/*Unlike the scale tables, we can't assume the maximum value will be in
index 0, so search for it here.*/
Modified: trunk/theora-exp/lib/enquant.h
===================================================================
--- trunk/theora-exp/lib/enquant.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/enquant.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -18,8 +18,7 @@
-void oc_quant_params_pack(oggpack_buffer *_opb,
- const th_quant_info *_qinfo);
+void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo);
void oc_enquant_tables_init(oc_quant_table *_dequant[2][3],
oc_quant_table *_enquant[2][3],const th_quant_info *_qinfo);
Modified: trunk/theora-exp/lib/fragment.c
===================================================================
--- trunk/theora-exp/lib/fragment.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/fragment.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -10,7 +10,11 @@
int i;
for(i=0;i<8;i++){
int j;
- for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(*_residue+++128);
+ for(j=0;j<8;j++){
+ int c;
+ c=*_residue+++128;
+ _dst[j]=OC_CLAMP255(c);
+ }
_dst+=_dst_ystride;
}
}
@@ -27,7 +31,11 @@
int i;
for(i=0;i<8;i++){
int j;
- for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(*_residue+++_src[j]);
+ for(j=0;j<8;j++){
+ int c;
+ c=*_residue+++_src[j];
+ _dst[j]=OC_CLAMP255(c);
+ }
_dst+=_dst_ystride;
_src+=_src_ystride;
}
@@ -47,7 +55,9 @@
for(i=0;i<8;i++){
int j;
for(j=0;j<8;j++){
- _dst[j]=OC_CLAMP255(*_residue+++((int)_src1[j]+_src2[j]>>1));
+ int c;
+ c=*_residue+++((int)_src1[j]+_src2[j]>>1);
+ _dst[j]=OC_CLAMP255(c);
}
_dst+=_dst_ystride;
_src1+=_src1_ystride;
Modified: trunk/theora-exp/lib/impmap.c
===================================================================
--- trunk/theora-exp/lib/impmap.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/impmap.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -464,8 +464,7 @@
_iplane: The image plane to sum the moments over.
This should already be adjusted to cover only the visible
frame, and not the full encoded frame.*/
-static void oc_seg_sum_moments(oc_seg_ctx *_seg,
- const th_img_plane *_iplane){
+static void oc_seg_sum_moments(oc_seg_ctx *_seg,const th_img_plane *_iplane){
const unsigned char *ypix;
int ymax;
int y;
@@ -507,7 +506,7 @@
_twidth: The width of the region in the table.
_theight: The height of the region in the table.
Return: The sum of the appropriate value over the given region.*/
-static float oc_seg_sum_region(const float **_sums,int _tx,int _ty,
+static float oc_seg_sum_region(/*const*/ float **_sums,int _tx,int _ty,
int _twidth,int _theight){
return _sums[_ty][_tx]-_sums[_ty][_tx+_twidth]-
_sums[_ty+_theight][_tx]+_sums[_ty+_theight][_tx+_twidth];
@@ -1344,8 +1343,7 @@
_iplane: The image plane the block is contained in.*/
static void oc_seg_splitmerge_bs(oc_seg_ctx *_seg,
int _x0,int _y0,int _width,int _height,int _level,
- int _area,float _sumx,float _sumx2,float _bic,
- const th_img_plane *_iplane){
+ int _area,float _sumx,float _sumx2,float _bic,const th_img_plane *_iplane){
const unsigned char *ypix;
int size;
int y;
@@ -1465,8 +1463,7 @@
_iplane: The image plane the block is contained in.*/
static void oc_seg_splitmerge_bt(oc_seg_ctx *_seg,
int _x0,int _y0,int _width,int _height,int _level,
- int _area,float _sumx,float _sumx2,float _bic,
- const th_img_plane *_iplane){
+ int _area,float _sumx,float _sumx2,float _bic,const th_img_plane *_iplane){
float sumx[4];
float sumx2[4];
float bic[4];
@@ -2110,10 +2107,10 @@
}
static void oc_impmap_fill(oc_impmap_ctx *_impmap,float _duration){
th_img_plane yplane;
- float imp_sum;
- int img_offset;
- int nmbs;
- int mbi;
+ float imp_sum;
+ int img_offset;
+ int nmbs;
+ int mbi;
/*Segment the Y plane.*/
/*TODO: Use the same oc_border_info structure as everyone else.
This would make future integration of an alpha mask easier.*/
@@ -2245,7 +2242,7 @@
oc_impmap_ctx *oc_impmap_alloc(oc_enc_ctx *_enc){
- th_info *info;
+ th_info *info;
oc_impmap_ctx *impmap;
int edge_sz;
int width;
Modified: trunk/theora-exp/lib/internal.c
===================================================================
--- trunk/theora-exp/lib/internal.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/internal.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -322,7 +322,7 @@
return (void **)ret;
}
-void oc_free_2d(void **_ptr){
+void oc_free_2d(void *_ptr){
_ogg_free(_ptr);
}
@@ -331,8 +331,7 @@
_dst: The destination buffer.
This can be the same as _src.
_src: The source buffer.*/
-void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,
- const th_ycbcr_buffer _src){
+void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,const th_ycbcr_buffer _src){
int pli;
for(pli=0;pli<3;pli++){
_dst[pli].width=_src[pli].width;
Modified: trunk/theora-exp/lib/internal.h
===================================================================
--- trunk/theora-exp/lib/internal.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/internal.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -10,7 +10,9 @@
# include "quant.h"
/*Thank you Microsoft, I know the order of operations.*/
-#pragma warning(disable:4554)
+# if defined(_MSCVER)
+# pragma warning(disable:4554)
+# endif
/*This library's version.*/
# define OC_VENDOR_STRING "derf's experimental encoder library " __DATE__
@@ -106,6 +108,8 @@
typedef int oc_sb_map[4][4];
/*A map from a macro block to fragment numbers.*/
typedef int oc_mb_map[3][4];
+/*A motion vector.*/
+typedef char oc_mv[2];
@@ -200,7 +204,7 @@
For fragments completely inside or outside this region, this is NULL.*/
oc_border_info *border;
/*The motion vector used for this fragment.*/
- char mv[2];
+ oc_mv mv;
}oc_fragment;
@@ -251,7 +255,7 @@
/*Common state information between the encoder and decoder.*/
struct oc_theora_state{
/*The stream information.*/
- th_info info;
+ th_info info;
/*Table for shared accelerated functions.*/
oc_base_opt_vtable opt_vtable;
/*CPU flags to detect the presence of extended instruction sets.*/
@@ -293,7 +297,7 @@
/*A copy of the image data used to fill the input pointers in each fragment.
If the data pointers or strides change, these input pointers must be
re-populated.*/
- th_ycbcr_buffer input;
+ th_ycbcr_buffer input;
/*The number of unique border patterns.*/
int nborders;
/*The storage for the border info for all border fragments.
@@ -302,7 +306,7 @@
/*The index of the buffers being used for each OC_FRAME_* reference frame.*/
int ref_frame_idx[3];
/*The actual buffers used for the previously decoded frames.*/
- th_ycbcr_buffer ref_frame_bufs[3];
+ th_ycbcr_buffer ref_frame_bufs[3];
/*The storage for the reference frame buffers.*/
unsigned char *ref_frame_data;
/*The frame number of the last keyframe.*/
@@ -333,8 +337,8 @@
_lmbmv: The luma macro-block level motion vector to fill in for use in
prediction.
_lbmvs: The luma block-level motion vectors.*/
-typedef void (*oc_set_chroma_mvs_func)(char _cbmvs[4][2],
- const char _lbmvs[4][2]);
+typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],
+ const oc_mv _lbmvs[4]);
@@ -368,10 +372,9 @@
int oc_ilog(unsigned _v);
void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz);
void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz);
-void oc_free_2d(void **_ptr);
+void oc_free_2d(void *_ptr);
-void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,
- const th_ycbcr_buffer _src);
+void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,const th_ycbcr_buffer _src);
int oc_dct_token_skip(int _token,int _extra_bits);
Modified: trunk/theora-exp/lib/ocintrin.h
===================================================================
--- trunk/theora-exp/lib/ocintrin.h 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/ocintrin.h 2007-05-03 04:22:07 UTC (rev 12912)
@@ -15,9 +15,6 @@
return (_a&~ambsign)+(_b&ambsign);
}*/
-static unsigned char oc_clamp255(int _x){
- return (unsigned char)(((_x<0)-1)&(_x|-(_x>255)));
-}
#define OC_MAXI(_a,_b) ((_a)<(_b)?(_b):(_a))
#define OC_MINI(_a,_b) ((_a)>(_b)?(_b):(_a))
@@ -28,7 +25,7 @@
_b: The value to clamp.
_c: The upper boud.*/
#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c)))
-#define OC_CLAMP255(_x) (oc_clamp255(_x))
+#define OC_CLAMP255(_x) ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
/*Divides an integer by a power of two, truncating towards 0.
_dividend: The integer to divide.
_shift: The non-negative power of two to divide by.
Modified: trunk/theora-exp/lib/quant.c
===================================================================
--- trunk/theora-exp/lib/quant.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/quant.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -43,10 +43,10 @@
}
for(qi=qri=0;qri<=_qinfo->qi_ranges[qti][pli].nranges;qri++){
th_quant_base base;
- ogg_uint32_t q;
- int qi_start;
- int qi_end;
- int ci;
+ ogg_uint32_t q;
+ int qi_start;
+ int qi_end;
+ int ci;
memcpy(base,_qinfo->qi_ranges[qti][pli].base_matrices[qri],
sizeof(base));
qi_start=qi;
Modified: trunk/theora-exp/lib/state.c
===================================================================
--- trunk/theora-exp/lib/state.c 2007-05-02 22:42:16 UTC (rev 12911)
+++ trunk/theora-exp/lib/state.c 2007-05-03 04:22:07 UTC (rev 12912)
@@ -445,7 +445,7 @@
factor of 2 on the appropriate sides.
_enc: The encoding context to store the buffers in.*/
static void oc_state_ref_bufs_init(oc_theora_state *_state){
- th_info *info;
+ th_info *info;
unsigned char *ref_frame_data;
size_t yplane_sz;
size_t cplane_sz;
@@ -586,10 +586,10 @@
void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli,
int _y0,int _yend){
th_img_plane *iplane;
- unsigned char *apix;
- unsigned char *bpix;
- unsigned char *epix;
- int hpadding;
+ unsigned char*apix;
+ unsigned char*bpix;
+ unsigned char*epix;
+ int hpadding;
hpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&1));
iplane=_state->ref_frame_bufs[_refi]+_pli;
apix=iplane->data+_y0*iplane->ystride;
@@ -612,12 +612,12 @@
_pli: The color plane.*/
void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli){
th_img_plane *iplane;
- unsigned char *apix;
- unsigned char *bpix;
- unsigned char *epix;
- int hpadding;
- int vpadding;
- int fullw;
+ unsigned char*apix;
+ unsigned char*bpix;
+ unsigned char*epix;
+ int hpadding;
+ int vpadding;
+ int fullw;
hpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&1));
vpadding=OC_UMV_PADDING>>(_pli!=0&&!(_state->info.pixel_fmt&2));
iplane=_state->ref_frame_bufs[_refi]+_pli;
@@ -633,19 +633,6 @@
}
}
-/*Duplicates the pixels on the border of the given reference image out into
- the surrounding padding for use by unrestricted motion vectors.
- _state: The context containing the reference buffers.
- _refi: The index of the reference buffer to pad.*/
-void oc_state_borders_fill(oc_theora_state *_state,int _refi){
- int pli;
- for(pli=0;pli<3;pli++){
- oc_state_borders_fill_rows(_state,_refi,pli,0,
- _state->ref_frame_bufs[_refi][pli].height);
- oc_state_borders_fill_caps(_state,_refi,pli);
- }
-}
-
/*Sets the buffer pointer in each fragment to point to the portion of the
image buffer which it corresponds to.
_state: The Theora state to fill.
@@ -664,7 +651,7 @@
memcpy(_state->input,_img,sizeof(th_ycbcr_buffer));
}
for(pli=0;pli<3;pli++){
- th_img_plane *iplane;
+ th_img_plane *iplane;
oc_fragment_plane *fplane;
oc_fragment *frag;
oc_fragment *vfrag_end;
More information about the commits
mailing list