Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 425725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:24:31+00:00 2026-05-12T19:24:31+00:00

I am trying to convert compressed swf files to uncompressed swf files using the

  • 0

I am trying to convert compressed swf files to uncompressed swf files using the cws2fws utility written by Alex Beregszaszi and which is part of the ffmpeg set of conversion routines. The compressed files I am using are valid files as they can be opened and played by Firefox and other programs, but when I run them through cws2fws the program gives an error (-5) indicating that the files is corrupt. I have downloaded the source for the program and compiled it using Visual Studio. When I run my file through the newly compiled program I get the same result as from the program I downloaded from the web. While debugging the program I noticed that the two of the four bytes that are used to determine the uncompressed file size of the swf are negative (see line 64 below).

00056     if (buf_in[0] != 'C' || buf_in[1] != 'W' || buf_in[2] != 'S')
00057     {
00058         printf("Not a compressed flash file\n");
00059         exit(1);
00060     }
00061 
00062     fstat(fd_in, &statbuf);
00063     comp_len = statbuf.st_size;
00064     uncomp_len = buf_in[4] | (buf_in[5] << 8) | (buf_in[6] << 16) | (buf_in[7] << 24);
00065 
00066     printf("Compressed size: %d Uncompressed size: %d\n", comp_len-4, uncomp_len-4);

So, my questions are:

1) I am feeling a bit dense, so could someone please explain the logic of determining the file size from the 4 bytes as shown in line 64. I understand that the size is probably the addition of a series of powers of 2 up to 2^32, but how are the bitwise operators working on the bytes to get the right number?

2) buf_in[5] and buf_in[6] are both negative which might be a problem between OS’s as I am on a windows machine and this code was developed apparently on a *nix machine. To me this indicates a bug in the program which has to do with signed and unsigned integers. Am I correct and how do I proceed?

3) Is it possible that this code can’t handle newer swf files?

4) Has anyone recently used this program with success?

Thanks for you help in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T19:24:31+00:00Added an answer on May 12, 2026 at 7:24 pm

    What is the type of buf_in? If it is char *, change it to unsigned char *: the signedness of char varies by platform and compiler and options, and clearly unsigned arithmetic is intended here. It is taking 4 bytes at offset 3 in buf_in and reading them as a little-endian 32-bit integer.

    That being said, I write a dumb little SWF decompresser eons ago.

    #!/usr/bin/perl
    use Compress::Zlib;
    undef $/;
    binmode(ARGV);
    while (<>) {
        my ($a, $b, $c) = unpack 'a3a5a*' => $_;
        if ($a eq 'CWS') {
            open FH, '>:raw', "${ARGV}.raw";
            syswrite FH, "FWS$b";
            syswrite FH, uncompress($c);
        }
    }
    

    Should work on any reasonable Perl installation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i´m using subsonic 3 trying convert a SQL2008 project to MySQL. when the projects
I've been trying to convert SVG images to PNG using C#, without having to
I'm trying to convert a bitmap image into an uncompressed tif file for use
I'm using lambda expression and trying convert into uint while adding into the Hashset.
Goal: Trying to convert some of the lines of an algorithm written in python
I'm trying convert xml from one format to other using the XslCompiledTransform in c#.
Trying to convert a JSON string into an object in C#. Using a really
Trying to convert an existing Android build system using Ant with 'ant_rules_r3.xml' integration from
When trying to convert the byte[] of Camera.onPreviewFrame to Bitamp using BitmapFactory.decodeByteArray gives me
I am currently trying to process a bunch of files with imagemagick using a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.