/** * _rb_track_transfer_batch_continue: * @batch: a #RBTrackTransferBatch * @overwrite: if %TRUE, overwrite the current file, otherwise skip * * Continues a transfer that was suspended because the current * destination URI exists. Only to be called by the #RBTrackTransferQueue. */ void _rb_track_transfer_batch_continue (RBTrackTransferBatch *batch, gboolean overwrite) { if (overwrite) { start_encoding (batch, TRUE); } else { track_transfer_completed (batch, 0, NULL, TRUE, NULL); } }
int main( int argc, char *argv[] ) { int ch1,ch2,ch3,ch4, syfreq, ltfreq; rangecoder rc; int prop[256]; if ((argc > 3) || ((argc>0) && (argv[1][0]=='-'))) usage(); if ( argc<1 ) fprintf( stderr, "stdin" ); else { freopen( argv[1], "rb", stdin ); fprintf( stderr, "%s", argv[1] ); } if ( argc<2 ) fprintf( stderr, " to stdout\n" ); else { freopen( argv[2], "wb", stdout ); fprintf( stderr, " to %s\n", argv[2] ); } fprintf( stderr, "%s\n", coderversion); #ifndef unix setmode( fileno( stdin ), O_BINARY ); setmode( fileno( stdout ), O_BINARY ); #endif int j; for(j=0;j<256;j++) prop[j]=32768; start_encoding(&rc,0,0); /* do the coding */ while (1) { unsigned char len; if ((ch1=getc(stdin))==EOF) break; len = ch1; //fprintf(stderr,"%d\n",len); int ctx=1; for(;ctx<256;) { encbit(&rc,len>>7,prop+ctx); ctx+=ctx+(len>>7); len+=len; } } done_encoding(&rc); return 0; }
static gboolean start_next (RBTrackTransferBatch *batch) { GstEncodingProfile *profile = NULL; if (batch->priv->cancelled == TRUE) { return FALSE; } if (batch->priv->entries == NULL) { /* guess we must be done.. */ g_signal_emit (batch, signals[COMPLETE], 0); g_object_notify (G_OBJECT (batch), "task-outcome"); return FALSE; } batch->priv->current_fraction = 0.0; rb_debug ("%d entries remain in the batch", g_list_length (batch->priv->entries)); while ((batch->priv->entries != NULL) && (batch->priv->cancelled == FALSE)) { RhythmDBEntry *entry; guint64 filesize; gulong duration; double fraction; GList *n; char *media_type; char *extension; n = batch->priv->entries; batch->priv->entries = g_list_remove_link (batch->priv->entries, n); entry = (RhythmDBEntry *)n->data; g_list_free_1 (n); rb_debug ("attempting to transfer %s", rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION)); /* calculate the fraction of the transfer that this entry represents */ filesize = rhythmdb_entry_get_uint64 (entry, RHYTHMDB_PROP_FILE_SIZE); duration = rhythmdb_entry_get_ulong (entry, RHYTHMDB_PROP_DURATION); if (batch->priv->total_duration > 0) { g_assert (duration > 0); /* otherwise total_duration would be 0 */ fraction = ((double)duration) / (double) batch->priv->total_duration; } else if (batch->priv->total_size > 0) { g_assert (filesize > 0); /* otherwise total_size would be 0 */ fraction = ((double)filesize) / (double) batch->priv->total_size; } else { int count = g_list_length (batch->priv->entries) + g_list_length (batch->priv->done_entries) + 1; fraction = 1.0 / ((double)count); } profile = NULL; if (select_profile_for_entry (batch, entry, &profile, FALSE) == FALSE) { rb_debug ("skipping entry %s, can't find an encoding profile", rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION)); rhythmdb_entry_unref (entry); batch->priv->total_fraction += fraction; continue; } if (profile != NULL) { media_type = rb_gst_encoding_profile_get_media_type (profile); extension = g_strdup (rb_gst_media_type_to_extension (media_type)); rb_gst_encoding_profile_set_preset (profile, NULL); if (batch->priv->settings != NULL) { GVariant *preset_settings; char *active_preset; preset_settings = g_settings_get_value (batch->priv->settings, "media-type-presets"); active_preset = NULL; g_variant_lookup (preset_settings, media_type, "s", &active_preset); rb_debug ("setting preset %s for media type %s", active_preset, media_type); rb_gst_encoding_profile_set_preset (profile, active_preset); g_free (active_preset); } } else { media_type = rhythmdb_entry_dup_string (entry, RHYTHMDB_PROP_MEDIA_TYPE); extension = g_strdup (rb_gst_media_type_to_extension (media_type)); if (extension == NULL) { extension = get_extension_from_location (entry); } } g_free (batch->priv->current_dest_uri); batch->priv->current_dest_uri = NULL; g_signal_emit (batch, signals[GET_DEST_URI], 0, entry, media_type, extension, &batch->priv->current_dest_uri); g_free (media_type); g_free (extension); if (batch->priv->current_dest_uri == NULL) { rb_debug ("unable to build destination URI for %s, skipping", rhythmdb_entry_get_string (entry, RHYTHMDB_PROP_LOCATION)); rhythmdb_entry_unref (entry); batch->priv->total_fraction += fraction; continue; } batch->priv->current = entry; batch->priv->current_entry_fraction = fraction; batch->priv->current_profile = profile; break; } if (batch->priv->current != NULL) { g_signal_emit (batch, signals[TRACK_STARTED], 0, batch->priv->current, batch->priv->current_dest_uri); start_encoding (batch, FALSE); g_object_notify (G_OBJECT (batch), "task-detail"); } return TRUE; }
int main( int argc, char *argv[] ) { int ch1,ch2,ch3,ch4, syfreq, ltfreq; rangecoder rc; //qsmodel qsm[48]; int prop[48]; if ((argc > 3) || ((argc>0) && (argv[1][0]=='-'))) usage(); if ( argc<1 ) fprintf( stderr, "stdin" ); else { freopen( argv[1], "rb", stdin ); fprintf( stderr, "%s", argv[1] ); } if ( argc<2 ) fprintf( stderr, " to stdout\n" ); else { freopen( argv[2], "wb", stdout ); fprintf( stderr, " to %s\n", argv[2] ); } fprintf( stderr, "%s\n", coderversion); #ifndef unix setmode( fileno( stdin ), O_BINARY ); setmode( fileno( stdout ), O_BINARY ); #endif /* make an alphabet with 257 symbols, use 256 as end-of-file */ #define SMALL 25 //#define SMALL 400 int j; for(j=0;j<48;j++) prop[j]=32768; // initqsmodel(&qsm[j],2,12,200,NULL,1); start_encoding(&rc,0,0); /* do the coding */ while (1) { int len; len = 0; if ((ch1=getc(stdin))==EOF) break; if ((ch2=getc(stdin))==EOF) break; if ((ch3=getc(stdin))==EOF) break; if ((ch4=getc(stdin))==EOF) break; len = ch4; len<<=8; len += ch3; len<<=8; len += ch2; len<<=8; len += ch1; //fprintf(stderr,"%d\n",len); int i=0; for(;;) { encbit(&rc,len&1,prop+i);i++; // qsgetfreq(&qsm[i],len&1,&syfreq,<freq); // encode_shift(&rc,syfreq,ltfreq,12); // qsupdate(&qsm[i],len&1); len>>=1; // i++; if (len==0) { encbit(&rc,1,prop+i); // qsgetfreq(&qsm[i],1,&syfreq,<freq); // encode_shift(&rc,syfreq,ltfreq,12); // qsupdate(&qsm[i],1); break; } encbit(&rc,0,prop+i);i++; // qsgetfreq(&qsm[i],0,&syfreq,<freq); // encode_shift(&rc,syfreq,ltfreq,12); // qsupdate(&qsm[i],0); // i++; len--; } } /* write 256 as end-of-file */ // qsgetfreq(&qsm1,SMALL,&syfreq,<freq); // encode_shift(&rc,syfreq,ltfreq,12); done_encoding(&rc); return 0; }