// Render "fake" highlights, because using actual dvd sub highlight elements // is too hard, and would require extra libavcodec to begin with. // Note: a proper solution would introduce something like // SD_CTRL_APPLY_DVDNAV, which would crop the vobsub frame, // and apply the current CLUT. void mp_nav_get_highlight(void *priv, struct mp_osd_res res, struct sub_bitmaps *out_imgs) { struct MPContext *mpctx = priv; struct mp_nav_state *nav = mpctx ? mpctx->nav_state : NULL; if (!nav) return; struct sub_bitmap *sub = nav->hi_elem; if (!sub) sub = talloc_zero(nav, struct sub_bitmap); nav->hi_elem = sub; if (!is_valid_size(nav->vidsize)) { update_resolution(mpctx); if (!is_valid_size(nav->vidsize)) return; } int sizes[2] = {nav->vidsize[0], nav->vidsize[1]}; if (sizes[0] != nav->subsize[0] || sizes[1] != nav->subsize[1]) { talloc_free(sub->bitmap); sub->bitmap = talloc_array(sub, uint32_t, sizes[0] * sizes[1]); memset(sub->bitmap, 0x80, talloc_get_size(sub->bitmap)); nav->subsize[0] = sizes[0]; nav->subsize[1] = sizes[1]; } out_imgs->num_parts = 0; if (nav->hi_visible) { sub->x = nav->highlight[0]; sub->y = nav->highlight[1]; sub->w = MPCLAMP(nav->highlight[2] - sub->x, 0, sizes[0]); sub->h = MPCLAMP(nav->highlight[3] - sub->y, 0, sizes[1]); sub->stride = sub->w * 4; if (sub->w > 0 && sub->h > 0) nav->outputs[out_imgs->num_parts++] = *sub; } if (nav->overlays[0]) nav->outputs[out_imgs->num_parts++] = *nav->overlays[0]; if (nav->overlays[1]) nav->outputs[out_imgs->num_parts++] = *nav->overlays[1]; if (out_imgs->num_parts) { out_imgs->parts = nav->outputs; out_imgs->format = SUBBITMAP_RGBA; osd_rescale_bitmaps(out_imgs, sizes[0], sizes[1], res, -1); } }
static void update_resolution(struct MPContext *mpctx) { struct mp_nav_state *nav = mpctx->nav_state; if (!nav) return; if (mpctx->d_sub[0]) sub_control(mpctx->d_sub[0], SD_CTRL_GET_RESOLUTION, nav->vidsize); if (!is_valid_size(nav->vidsize)) { struct mp_image_params vid = {0}; if (mpctx->d_video) vid = mpctx->d_video->decoder_output; nav->vidsize[0] = vid.w; nav->vidsize[1] = vid.h; } }
static void update_resolution(struct MPContext *mpctx) { struct mp_nav_state *nav = mpctx->nav_state; int size[2] = {0}; if (mpctx->d_sub[0]) sub_control(mpctx->d_sub[0], SD_CTRL_GET_RESOLUTION, size); if (!is_valid_size(size)) { struct mp_image_params vid = {0}; if (mpctx->d_video) vid = mpctx->d_video->decoder_output; size[0] = vid.w; size[1] = vid.h; } pthread_mutex_lock(&nav->osd_lock); nav->vidsize[0] = size[0]; nav->vidsize[1] = size[1]; pthread_mutex_unlock(&nav->osd_lock); }
/** * @brief Decompresses a .palz file * @details Function receives a filename, opens it, verifies that it is a valid .palz file with a valid dictionary and starts the proceedures to decompress the file into a new file, or itself, depending on whether or not the file given has a .palz extension. * * @param filename Pointer to filename. */ void decompress (char *filename, int function) { //Open the given file FILE *myFile = NULL; myFile = fopen(filename, "r"); //Read the first line for PALZ headline char *line = NULL; size_t len = 0; ssize_t read; read = getline(&line, &len, myFile); int palz = is_header_PALZ(line); //Verify if it's a valid .palz file. if (!palz){ fprintf(stderr, "Failed: %s is not a valid .palz file\n", filename); fclose(myFile); if(function ==1) { exit(1); } else { FREE (line); return; } } //Read the second line for the number of words read = getline(&line, &len, myFile); unsigned int numberOfWords = 0; int size = is_valid_size(line, &numberOfWords, filename); if (!size) { if(function == 1) { exit(1); } else { FREE (line); return; } } //Allocate memory for the words char **words = MALLOC (sizeof(char*)*(numberOfWords+DICT)); //Read each line in the file until the number of words indicated in the header has been reached. unsigned int i = 0; while (running && i < numberOfWords) { read = getline(&line, &len, myFile); if(read == -1) { fprintf(stderr, "Failed: %s is corrupted\n", filename); if(function ==1) { exit(1); } else { FREE (line); FREE (words); return; } } line [read-1]=0; //Removes the line break words [i+DICT] = strdup(line); i++; } //Initialize the dictionary words[1]="\n"; words[3]="\r"; words[2]="\t"; words[4]=" "; words[5]="?"; words[6]="!"; words[7]="."; words[8]=";"; words[9]=","; words[10]=":"; words[11]="+"; words[12]="-"; words[13]="*"; words[14]="/"; //Verify dictionary file if(sizeof(words) >= pow(2,24)) { fprintf(stderr,"Failed: %s dictionary is too big\n", filename); } //start decompression and write to file write_to_file(words, filename, myFile, numberOfWords, function); unsigned int auxis; for (auxis = DICT; auxis < numberOfWords+DICT; auxis++){ FREE(words[auxis]); } FREE(words); FREE (line); }