| synopsis || return value || arguments || prev || next |

kdu_codestream::trans_out

Java: Kdu_codestream::Trans_out

int trans_out( kdu_long max_bytes=KDU_LONG_MAX, kdu_long * layer_bytes=NULL, int layer_bytes_entries=0, bool record_in_comseg=false)

Java: int Trans_out( long max_bytes, long[] layer_bytes, int layer_bytes_entries, boolean record_in_comseg)

[Declared in "../coresys/common/kdu_compressed.h"]

Go to class description.


Synopsis

Use this output function instead of flush when the code-stream has been created by a transcoding operation which has no real distortion information. In this case, the individual code-block pass_slopes values are expected to hold 0xFFFF-layer_idx, where layer_idx is the zero-based index of the quality layer to which the code-block contributes (the pass slope value is 0 if a later pass contributes to the same layer). This policy is described in the comments appearing with the definition of kdu_block::pass_slopes.

A modified form of the rate allocation algorithm is used to write output quality layers with the same code-block contributions as the quality layers in the input codestream which is being transcoded.

If the existing layers exceed the max_bytes limit, empty packets are written for any complete quality layers which are to be discarded and partial layers are formed by discarding code-blocks starting from the highest frequency subbands and the bottom of the image.

Like the flush function, trans_out may be invoked multiple times to incrementally flush the code-stream contents, based on availability. Each time the function is called, the function writes as much of the code-stream as it can, given the availability of compressed data, and the current packet progression sequence. The same restrictions and recommendations supplied with the description of the flush function in regard to incremental flushing apply here also. In particular, you should remember that each call generates new tile-parts, that the maximum number of tile-parts for any tile is 255, and that the rate control associated with a supplied max_bytes limit is most effective if the function is called as infrequently as possible. The value of the max_bytes argument is ignored for all but the first call to this function, at which point it is recorded internally for use in incrementally sizing the incrementally generated code-stream data in a uniform and consistent manner.

If the layer_bytes argument is non-NULL, it points to an array with layer_bytes_entries entries. Upon return, the entries in this array are set to the cumulative number of bytes written to each successive quality layer so far. If the array contains insufficient entries to cover all available quality layers, the total code-stream length will generally be larger than the last entry in the array, upon return.


Return Value

The number of non-empty quality layers which were generated. This may be less than the number of layers in the input codestream being transcoded if max_bytes presents an effective restriction.

Arguments

max_bytes [kdu_long]

Maximum number of compressed data bytes to write out. If necessary, one or more quality layers will be discarded, and then, within the last quality layer, code-blocks will be discarded in order, starting from the highest frequency subbands and working toward the lowest frequency subbands, in order to satisfy this limit.

layer_bytes [kdu_long *]

If non-NULL, the supplied array has layer_bytes_entries entries and is used to return the number of bytes written so far into each quality layer.

layer_bytes_entries [int]

Number of entries in the layer_bytes array. Ignored if layer_bytes is NULL.

record_in_comseg [bool]

If true, the size and "rate-distortion" slope information will be recorded in a main header COM (comment) marker segment, for each quality layer. While this may seem appropriate, it often is not, since fake R-D slope information is synthesized from the quality layer indices. As a general rule, you should copy any COM marker segments from the original code-stream into the new one when transcoding.


| top || synopsis || return value || arguments || prev || next |